Last Sync: 2022-05-23 19:30:04
This commit is contained in:
parent
fafc020e89
commit
68fea6a8dc
1 changed files with 21 additions and 7 deletions
|
@ -4,27 +4,35 @@ tags:
|
||||||
- shell
|
- shell
|
||||||
- automation
|
- automation
|
||||||
---
|
---
|
||||||
j
|
# Cron
|
||||||
|
|
||||||
In Arch Linux I use `cronie` for cron jobs. (There is no cron service installed by default).
|
In Arch Linux I use `cronie` for cron jobs. (There is no cron service installed by default).
|
||||||
|
## Commands
|
||||||
|
|
||||||
````bash
|
### List cron jobs
|
||||||
|
```
|
||||||
# View list of cron jobs
|
|
||||||
crontab -l
|
crontab -l
|
||||||
|
```
|
||||||
|
|
||||||
# Open cron file
|
### Open cron file
|
||||||
|
```
|
||||||
crontab -e
|
crontab -e
|
||||||
````
|
```
|
||||||
|
### Check cron log
|
||||||
|
```bash
|
||||||
|
|
||||||
\*\*Syntax **
|
journalctl | grep CRON
|
||||||
|
# Different distros have different loggers
|
||||||
|
```
|
||||||
|
|
||||||
|
## Syntax
|
||||||
````bash
|
````bash
|
||||||
m h d mon dow command
|
m h d mon dow command
|
||||||
# minute, hour, day of month, day of week, bash script/args
|
# minute, hour, day of month, day of week, bash script/args
|
||||||
# 0-59, 0-23, 1-31, 1-12, 0-6
|
# 0-59, 0-23, 1-31, 1-12, 0-6
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|
||||||
**Examples**
|
**Examples**
|
||||||
|
|
||||||
Run on the hour every hour
|
Run on the hour every hour
|
||||||
|
@ -39,6 +47,12 @@ At 01:42 every day:
|
||||||
42 1 * * * mysqlcheck --all-databases --check-only-changed --silent
|
42 1 * * * mysqlcheck --all-databases --check-only-changed --silent
|
||||||
````
|
````
|
||||||
|
|
||||||
|
Every half hour:
|
||||||
|
```
|
||||||
|
0,30 * * * * ${HOME}/bash_scripts/automate_commit.sh
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
**Shorthands**
|
**Shorthands**
|
||||||
|
|
||||||
* `@reboot` – Run once, at startup
|
* `@reboot` – Run once, at startup
|
||||||
|
|
Loading…
Add table
Reference in a new issue