linux_wiki:schedule_tasks_using_at_and_cron

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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/how-to/script.  
- 
----- 
- 
-==== 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 
-</code> 
- 
-Example Times (teatime is 4pm) 
-<code bash> 
-at now +5 minutes 
-at now +5 hours 
-at 12:00am 
-at teatime 
-<enter command> <ctrl+d> 
-</code> 
- 
-Example job 
-<code bash> 
-at now +5 minutes 
-at>logger "System uptime is:$(uptime)" 
-at> <ctrl+d> 
-</code> 
- 
-View jobs 
-<code bash> 
-atq 
-</code> 
- 
-Remove job (cancel job) 
-<code bash> 
-atrm <job#> 
-</code> 
- 
----- 
- 
-==== cron ==== 
- 
-cron is for scheduling reoccurring jobs/scripts. 
- 
-Edit current user's cron 
-<code bash> 
-crontab -e 
-</code> 
- 
-System wide 
-<code bash> 
-/etc/crontab 
- 
-# .---------------- minute (0 - 59) 
-# |  .------------- hour (0 - 23) 
-# |  |  .---------- day of month (1 - 31) 
-# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ... 
-# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat 
-# |  |  |  |  | 
-# *  *  *  *  * user-name  command to be executed 
-</code> 
- 
-More preferred method: Place scripts inside one of the cron.* directories. 
-  * /etc/cron.d/ = system executed jobs (format => /etc/crontab) 
-  * /etc/cron.daily/ = daily executed scripts (format => bash script) 
-  * /etc/cron.hourly/ = hourly executed scripts (format => bash script) 
-  * /etc/cron.monthly/ = monthly executed scripts (format => bash script) 
-  * /etc/cron.weekly/ = weekly executed scripts (format => bash script) 
- 
-Example custom script in /etc/cron.d 
-<code bash> 
-*/5 * * * * root /home/user/uptimelog 
-</code> 
-  * Executes /home/user/uptimelog as root, every 5 mins 
- 
----- 
  
  • linux_wiki/schedule_tasks_using_at_and_cron.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)