- Cron job are used to schedule commands to be executed periodically.
- can setup set up commands or scripts, which will repeatedly run at a set time.
- The cron service (daemon) runs in the background and constantly checks the /etc/crontab file,
- To edit your crontab file, type the following command at the UNIX / Linux shell prompt: $ crontab -e
Example :
1 2 3 4 5 /root/email_notifications.sh argument1 argument2
Where
- 1 Minutes (0-59)
- 2 Hours (0-23)
- 3 Day of Month (1-31)
- 4 Month (1-12)
- 5 Day of Week (0-7) Sunday=0
Run the invoice program in working hours only
00 09-18 * * 1-5 invoice_sh "Customer_Number"
Run the program concurrent_fail_list_sh in every 10 mins
*/10 * * * * concurrent_fail_list_sh
Run the program customer_info_sh for every mins
* * * * * customer_info_sh
Special Key words
Keyword | Equivalent |
@yearly | 0 0 1 1 * |
@daily | 0 0 * * * |
@hourly | 0 * * * * |
@reboot | Run at startup. |
Run the program customer_info_sh yearly once
@yearly customer_info_sh
Run the program customer_info_sh daily once
@daily customer_info_sh
Run the program customer_info_sh hourly once
@hourly customer_info_sh
Run the program customer_info_sh after system boot up
@reboot customer_info_sh
List the scheduled jobs for particular user
$crontab -u username -l
Add the new job in crontab use the below commands
$crontab -e
No comments:
Post a Comment