/usr/lib/cron/cron.allow
" exists, then the user name must be listed therein, otherwise the user will not be allowed to use the crontab command./usr/lib/cron/cron.deny
" exists, then the user name must not be listed therein, otherwise the user will not be allowed to use the crontab command.$ crontab -e # this command "echo `date` >> /home/user1/crontab_test.log" will be executed every minute * * * * * echo `date` >> /home/user1/crontab_test.log
# crontab: no crontab for user1 - using an empty one # crontab: installing new crontab
$ crontab -l * * * * * echo `date` >> /home/user1/crontab_test.log
$ sudo ls -l /usr/lib/cron/tabs -rw------- 1 root root 284 14 Feb 09:00 user1
$ cat /home/user1/crontab_test.log Sun Feb 25 09:01:00 EST 2014 Sun Feb 25 09:02:00 EST 2014 Sun Feb 25 09:03:00 EST 2014 Sun Feb 25 09:04:00 EST 2014
$ sudo crontab -e -u user2 # this command "echo `date` >> /home/user2/crontab_test.log" will be executed every minute * * * * * echo `date` >> /home/user2/crontab_test.log
crontab: no crontab for user2 - using an empty one crontab: installing new crontab
$ sudo ls -l /usr/lib/cron/tabs -rw------- 1 root root 285 14 Feb 09:35 user2 -rw------- 1 root root 284 14 Feb 09:00 user1
-u |Specify the name of the user whose crontab is to be used. |If this option is not given, the crontab of the current user is used. |This option is important when using "su" to run the crontab command. -l |Display the current crontab on standard output. -r |Remove the current crontab. -e |Edit the crontab using the editor specified by the VISUAL or EDITOR environment variables. |After exiting the editor, the modified crontab will be applied automatically.
min: [0 - 59] hour: [0 - 23] day: [1 - 31] month: [1 - 12] day of week: [0 - 7] (check your system if 0 or 7 reference Sunday)
*: match any value of the allowed values -: specify a range of values: 9-15 (means any value between 9 and 15) ,: specify a list of values or range of values: 7,9-15,35 (means 7, any value between 9 and 15, and 35) /: specify steps over a range of values: */3 (for hours, every 3 hours), 8/2 (for hours, every 2 hours starting from 8h) name_of_the_day: use the first three letters of the day (ranges or lists of names are not allowed) name_of_the_month: use the first three letters of the month (ranges or lists of names are not allowed)