Coding Knowledge Center
|Anacron (Config file)|
Configuration file location for anacron.
SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin #format: period delay job-identifier command 1 5 cron.daily run-parts /etc/cron.daily 7 10 cron.weekly run-parts /etc/cron.weekly 30 15 cron.monthly run-parts /etc/cron.monthly
This is pretty much the default anacron setup. You can populate shell variables as needed in this anacrontab configuration file. The first command is run once per day after a 5 minute delay upon anacron start up. The next command runs once per week after a 10 minute delay upon anacron start up. The final command runs once per month after a 15 minute delay upon anacron start up. run-parts is the command to run and what follows is a directory parameter the program will use.
period delay indentifier command
field 1: how frequent in days to run [days] field 2: delay between start of anacron to program execution [minutes] field 3: string which identifies the command field 4: command to execute
at -f [file w/ commands] [time]
Time Specifications HH:MM (military time) HH:MM AM/PM (12 hour clock) noon, midnight, teatime (4pm) HH:MM MMDDYY HH:MM MM/DD/YY HH:MM DD.MM.YY HH:MM month-name day HH:MM month-name day year now + 2
bash$ at [time] at> [command] at> [command] at> [command] at> ...etc ... at> CTRL-D (to end)
Typing the at command with a specified time puts the user on the "at" command prompt. From here the user enters commands that they wish to run at that specified time. When done entering commands, hit CTRL-D to exit.
|Cron (Edit cronjob entries)|
Edit current list of cron job entries.
|Cron (Example 1)|
SHELL=/bin/bash MAILTO=steved HOME=/home/steved * 12 10-16/2 * * my_command * 12 10,12,14,16 * * my_command
Again you can specify shell variables such as SHELL, MAILTO and HOME in the crontab configuration file. Run my_command at noon every 2 days from the 10th thru the 16th (10th, 12th, 14th, 16th)
|Cron (Example 2)|
*/15 9-17 * * * my_command
Run my_command every 15 minutes between 9am and 5pm everyday
|Cron (Example 3)|
00 00 15 10-12 * my_command
Run my_command on the 15th day of October, November and December at midnight
|Cron (Example 4)|
00 06 * * 0 my_command
Run my_command every Sunday at 6am
* * * * * command
field *: non-specified field field 1: minute [0-59] field 2: hour [0 (Midnight) - 23 (11pm)] field 3: day of month [1-31] field 4: month [0 (January) - 11 (December)] field 5: day of the week [0 (Sunday) - 7 (Saturday)] field 6: command to run Delimiters - = specify a range , = seperate multiple values / = specify interval
|Cron (List cronjob entries)|
List current crontab job entries.
|Cron (Remove cronjob entries)|
BE CAREFULL!!! Removes all of the user's crontab entries!!!
crontab -u [user] [file]
Specify a crontab user and the cronjob configuration file to use.