Hi All,
Here is yet another example of the format that you need to us for the crontab entries…
38 2 * * 7 root /usr/bin/something.sh
The first bit is a range from 0-59 Minutes = 38min currenly
The second bit is a range of 0-23 Hours = 2hr currently
The thrid bit is a range of 1-31 Day of Month = * currnetly all open
The fourth bit is a range of 1-12 Month = * currently all open
Jan =1, Feb=2, Mar=3, Apr=4, May=5, June=6, July=7, Aug=8
Sep=9, Oct=10, Nov=11, Dec=12
The fifth bit is a range of 1-7 Day of Week = * 7 currently
Sun=0, Mon=1, Tue=2, Wed=3, Thr=4, Fri=5, Sat=6, Sun=7
The six bit is the user you whis to execute the command
The seventh bit is the command line to run
Examples below:
Crontab Example 1:
This crontab example runs updatedb command 35 minutes past every hour.
35 * * * * updatedb
Crontab Example 2:
This crontab example runs /usr/local/bin/diskusage.sh every 5 minutes (e.g. 0, 5, 10, 15, …).
*/5 * * * * /usr/local/bin/diskusage.sh
Crontab Example 3:
This crontab example runs /usr/local/bin/diskusage.sh at 1:25 AM, 1:50 AM every Tuesday and on 15th of every month.
25,50 1 15 * 2 /usr/local/bin/diskusage.sh
Crontab Example 4:
This crontab example runs /usr/local/bin/diskusage.sh at 2:00 PM on 10th of March, June, September and December.
00 14 10 3,6,9,12 * /usr/local/bin/diskusage.sh
Crontab Example 5:
This crontab example runs ‘/usr/local/bin/diskusage.sh user@linuxconfig.sh’ at 9.00 PM every Monday, Wednesday, Friday. Note: Using names for the week day and months is extension in some versions of crontab.
00 21 * * Mon,Wed,Fri /usr/local/bin/diskusage.sh user@onling.sh
Crontab Example 6:
This crontab example runs /usr/local/bin/diskusage.sh every 5 minutes during the 5 working days (Monday - Friday), every week and month.
*/5 * * * 1-5 /usr/local/bin/diskusage.sh
Crontab Example 7:
This crontab example runs /usr/local/bin/diskusage.sh every minute during the 4-th hour only in Sunday, every week and month. This is every minute from 0:00 till 0:59, then from 4:00 till 4:59, etc.
* */4 * * sun /usr/local/bin/diskusage.sh
System wide cron scheduler
As A Linux administrator you can also use predefined cron directories:
/etc/cron.d
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
Cron Scheduler on user level
Every user can edit, view or remove his onw crontab file. If the root user needs to change someoneelse’s crontab file he must add ‘-u’ option to specify the user name. To edit crontab file for user foobar we can use command:
crontab -u foobar -e
Remove foobar’s crontab file:
crontab -u foobar -r
To view foobar’s crontab content:
crontab -u foobar -l