|
|||||||
|
Cron - Program SchedulerYour Virtual Private Server includes access to the cron daemon which is used to automatically execute scheduled commands. The list of commands you schedule cron to run is stored in a cron table, or crontab. Using your own crontab, you can schedule your Virtual Private Server to run a certain command at a predetermined date and time. Creating a CrontabYour Virtual Private Server crontab can be stored in any file you choose. For example, you may wish to create or upload a file called cronjobs in your Virtual Private Server home directory for your crontab. Each line in your crontab will either be an environment variable setting, a cron table entry, or a comment (beginning with the # symbol). An environment variable setting in a crontab looks like this: NAME = VALUE Several environment variables are set up automatically by the cron daemon, depending on your Virtual Private Server O/S.
The format of a cron table entry includes five (5) time fields followed by a command. Commands are executed when the time specified by the date fields matches the current time. The five time fields are as follows:
A field may be an asterisk (*), which indicates all values in the range are acceptable. Ranges of numbers are allowed, i.e. 2-5 or 8-11, and lists of numbers are allowed, i.e. 1,3,5 or 1,3,8-11. Step values can be represented as a sequence, i.e. 0-59/15, 1-31/3, or */2. The actual command you wish to execute, including any parameters to be passed to it, is the sixth, and final field of a cron table entry.
Some examples of complete cron table entries are show below, implementing the vnukelog command as an example. # Any output generated by the cron entries below is sent to the e-mail # address assigned to the MAILTO environment variable. MAILTO="webmaster@mycompany.com" # Execute the "vnukelog" command at 1:15 (15 1) AM every day. 15 1 * * * /usr/local/bin/vnukelog # Execute the "vnukelog" command at 11:40 PM (40 23) on the first day (1) # of each month. 40 23 1 * * /usr/local/bin/vnukelog # Execute the "vnukelog" command every 10 minutes for for the first # half-hour (0-30/10) of the 9:00 AM and 5:00 PM hours (9,17) on # Monday-Friday (1-5). 0-30/10 9,17 * * 1-5 /usr/local/bin/vnukelog # Execute the "vnukelog" command at 4:00 AM, 8:00 AM, 12:00 noon, 4:00 PM, # and 8:00 PM (0 */4) on each Sunday (sun) every January (jan). 0 */4 * jan sun /usr/local/bin/vnukelog # Execute the "vnukelog" command at 4:30 AM (30 4) on the first, fifteenth # (1,15), and each Friday (fri) of every month. 30 4 1,15 * fri /usr/local/bin/vnukelog # Execute the "vnukelog" command at 12:00 midnight (0 0) on August 19 (8) # (aug). 0 0 19 8 * /usr/local/bin/vnukelog 0 0 19 aug * /usr/local/bin/vnukelog Installing a CrontabAfter you have defined the cron table entries in your cronjobs file, you will need to register your crontab with the system. This can be done by running the crontab command. For example, if you created your crontab file with the name cronjobs in your Virtual Private Server home directory then you would use the following command: % crontab ~/cronjobs This will register your crontab file with the cron system daemon. If you ever need to review the current cron entries you have registered with the cron system daemon, you need simply use this command: % crontab -l DocumentationIssue the following commands to view the cron and crontab man pages. % man cron% man crontab% man 5 crontab |
||||||
|
Send mail to: mailto:webmaster@littletechshoppe.com with questions or comments about this web site. Copyright © 1996-2004. A Little Technology Shoppe, LLC (alts.net®). All rights reserved. Netscape and the Netscape Logo are registered trademarks of Netscape Communications Corp. Microsoft is a registered trademark and the Microsoft Internet Explorer Logo is a trademark of Microsoft. All trademarks are owned by the respective company or A Little Technology Shoppe, LLC. | |||||||