– Its a utility that allows you to run specific job at regular specified interval.
– It is mostly used and trusted scheduling utility in Linux/UNIX environment.
– We have covered almost all the examples here.
Examples:
_______________________________________________________________
# crontab -eu mike
————————————–
* * * * * /bin/echo “Hello”
————————————–
# chkconfig crond on
# service crond restart
– To see crontab
# crontab -lu mike
or
# crontab -l
– To stop scheduler for all users
# chkconfig crond off
# service crond stop
– To stop scheduler for particular user
# crontab -eu mike
– To remove the crontab
# crontab -r
– To display last time edited
# crontab -v
|
—————————————————————————-
min hour day of month mount day of week
—————————————————————————-
M H D M D
|
– To disable the crontab emails, add following line at last of crontab entry
>/dev/null 2>&1
|
– For every minute
———————————–
* * * * * /echo/bin
———————————–
– For every hour
———————————–
0 * * * * /echo/bin
———————————–
– For every day
———————————–
0 0 * * * /echo/bin
———————————–
– For every month
———————————–
0 0 1 * * /echo/bin
———————————–
– For every Monday
———————————–
0 0 1 1 1 /echo/bin
———————————–
|
– For every 5 minute
———————————–
*/5 * * * * /echo/bin
———————————–
– For every 2 hours
———————————–
0 */2 * * * /echo/bin
———————————–
– For every alternate day
———————————–
0 0 */2 * * /echo/bin
———————————–
– For every alternate month
———————————–
0 0 1 */2 * /echo/bin
———————————–
|
– Daily at 9AM, 12PM, 3PM
———————————–
0 9,12,15 * * * /echo/bin
———————————–
– On 4th, 10th and 12th of every month
———————————–
0 0 4,10,12 * * /echo/bin
———————————–
– In Feb and March only
———————————–
0 0 1 2,3 * /echo/bin
———————————–
– On Monday, Tuesday only
———————————–
0 0 * * 1,3 /echo/bin
———————————–
|
– For every 10 to 15 minutes
———————————–
10-15 0 * * * /echo/bin
———————————–
– For within working hours
———————————–
0 9-17 * * * /echo/bin
———————————–
– For 15 to 15th of the month
———————————–
0 0 15-25 * * /echo/bin
———————————–
– For June to November of the year
———————————–
0 0 * 6-11 * /echo/bin
———————————–
– For every working days
———————————–
0 0 * * 1-5 /echo/bin
———————————–
|
– For the mentioned timing “11:00 AM 27June 2013”
———————————–
0 11 27 6 * /echo/bin
———————————–
– Two times a day
———————————–
0 11,20 27 6 * /echo/bin
———————————–
– On weekdays
———————————–
0 11 27 6 1-5 /echo/bin
———————————–
– On working hours
———————————–
0 10-17 27 6 * /echo/bin
———————————–
|
– At mid night everyday
———————————–
0 0 * * * /echo/bin
———————————–
– Every 1st of month, at mid night
———————————–
0 0 1 * * /echo/bin
———————————–
– On every Monday, at 12 noon
———————————–
0 12 * * 1 /echo/bin
———————————–
– After every 15 days at mid night
———————————–
0 0 27 * * /echo/bin
———————————–
– For every 10 minutes, disk space
———————————–
*/10 * * * * /check_disk_space
———————————–
|
– After every reboot
———————————–
@reboot /disk_space_check
———————————–
– After every year
———————————–
@yearly /echo/bin
———————————–
– After every day
———————————–
@daily /echo/bin
———————————–
– After every hour
———————————–
@hourly /echo/bin
———————————–
|
– You can use the notification, by using “notify-send”
———————————–
0 11 27 6 * /echo/bin notify-send “Backup completed”
———————————–
– Can use pop-up messages using, “xmessage”
———————————–
0 11 27 6 * /echo/bin xmessage -file /path/message.txt
———————————–
– To send cron job O/P as a mail to any specific user
———————————–
MAILTO=”santosh”
0 11 27 6 * /echo/bin xmessage -file /path/message.txt
———————————–
|