Differences
This shows you the differences between two versions of the page.
linux_wiki:schedule_tasks_using_at_and_cron [2016/02/29 21:44] billdozor created |
linux_wiki:schedule_tasks_using_at_and_cron [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Schedule Tasks Using At And Cron ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | About this page/ | ||
- | |||
- | ---- | ||
- | |||
- | ==== at ==== | ||
- | at is good for one-off jobs that don't need to reoccur regularly. | ||
- | |||
- | Install, Enable, Start | ||
- | <code bash> | ||
- | yum install at | ||
- | systemctl enable atd | ||
- | systemctl start atd | ||
- | </ | ||
- | |||
- | Example Times (teatime is 4pm) | ||
- | <code bash> | ||
- | at now +5 minutes | ||
- | at now +5 hours | ||
- | at 12:00am | ||
- | at teatime | ||
- | <enter command> < | ||
- | </ | ||
- | |||
- | Example job | ||
- | <code bash> | ||
- | at now +5 minutes | ||
- | at> | ||
- | at> < | ||
- | </ | ||
- | |||
- | View jobs | ||
- | <code bash> | ||
- | atq | ||
- | </ | ||
- | |||
- | Remove job (cancel job) | ||
- | <code bash> | ||
- | atrm < | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ==== cron ==== | ||
- | |||
- | cron is for scheduling reoccurring jobs/ | ||
- | |||
- | Edit current user's cron | ||
- | <code bash> | ||
- | crontab -e | ||
- | </ | ||
- | |||
- | System wide | ||
- | <code bash> | ||
- | / | ||
- | |||
- | # .---------------- minute (0 - 59) | ||
- | # | .------------- hour (0 - 23) | ||
- | # | | .---------- day of month (1 - 31) | ||
- | # | | | .------- month (1 - 12) OR jan, | ||
- | # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun, | ||
- | # | | | | | | ||
- | # * * * * * user-name | ||
- | </ | ||
- | |||
- | More preferred method: Place scripts inside one of the cron.* directories. | ||
- | * / | ||
- | * / | ||
- | * / | ||
- | * / | ||
- | * / | ||
- | |||
- | Example custom script in /etc/cron.d | ||
- | <code bash> | ||
- | */5 * * * * root / | ||
- | </ | ||
- | * Executes / | ||
- | |||
- | ---- | ||