To view specif user cron jobs : contrab -l
To edit users cron : crontab -e [before that export EDITOR=vi]
Location of users cron file: /var/spool/cron/crontrabs
System wide cron scheduler : /etc/crontab
Syntax
min hr dom month dow cmd [user specific]
min hr dom month dow user cmd [global configuration]
Special note
to run every 5minutes
*/5 – in linux
0-59/5 in solaris
Few scenario –
Schedule a Job For More Than One Instance (e.g. Twice a Day)
The following script take a incremental backup twice(11,16) a day every day.
00 11,16 * * * /home/ramesh/bin/incremental-backup
Schedule a Job for Specific Range of Time (e.g. Only on Weekdays)
If you wanted a job to be scheduled for every hour with in a specific range of time then use the following.
Cron Job everyday during working hours
This example checks the status of the database everyday (including weekends) during the working hours 9 a.m – 6 p.m
00 09-18 * * * /home/ramesh/bin/check-db-status
Cron Job everyday during working hours and every 30 minutes within specified hours
0,30 09-18 * * * /home/ramesh/bin/check-db-status
Cron Job every weekday during working hours
This example checks the status of the database every weekday (i.e excluding Sat and Sun) during the working hours 9 a.m – 6 p.m.
00 09-18 * * 1-5 /home/ramesh/bin/check-db-status
Leave a comment