|
|
||||
The Cron time application server is available in some form or another on all modern Unix systems. Using cron, webmasters can automate many tasks including running scripts, controlling hardware (webcams), updating databases etc. Cron consists of two main programs:
As Cron is standardized, if you are familiar with Vixie Cron, or Dillon's Cron (two popular Cron software packages), you will have no problem using the Cron tools available on your server.
The crontab tool is used to create, edit, view and delete your Cron tables. The Cron tables are the files that contain the lists of jobs or scripts you want the server to run at certain times or events.
To edit your Cron table, simply type crontab -e at your command prompt. If you haven't set up any tasks, your Cron table will be empty. Here is an example of a Cron table featuring one task:
# 30 minute webcam update 30 * * * * /cam/webcam_upd.pl
The hash mark preceding the first line signifies that the line is a comment. The actual command contained in this table is on line 2. Reading this line is pretty easy, here is a breakdown of what each phrase means:
Here are some other examples of Cron table entries:
* */2 * * Mon,Fri /run_every_2_hours_onMF.pl
The "*/2" specifies that this script will run every two hours, and the "Mon,Fri" designates that this will only occur on Mondays and Fridays. It could have also been written as * */2 * * 1,5 /run_every_2_hours_onMF.pl with Monday and Friday being represented by the "1" and "5" respectively.
* 2am */5,1,31 * * /cron/run_every_5_days_and_1st_and_31st.pl
This entry specifies the script will run every 5 days and also on the 1st and 31st on the month.
In addition to the editing mode of crontab, accessed with -e, there are two other switches you can use. To simply display the contents of your Cron table, type crontab -l. To delete your Cron table, use crontab -r.
On most Unix systems, At and Cron work independently but can be used to perform similar tasks. Where Cron is used to perform tasks repeatedly, At is used to run commands or programs just once. For more information on this, please see Using At to Schedule One-time Jobs.
Related Items
Related Items