Last Sync: 2022-05-23 19:30:04

This commit is contained in:
tactonbishop 2022-05-23 19:30:04 +01:00
parent fafc020e89
commit 68fea6a8dc

View file

@ -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