"What is crontab you ask?" All crontab is - is kind of like an alarm clock. It's a TASK SCHEDULER. It's just a text file you create on your webserver.

0 * * * * /etc/reset.cgi
0 0 * * * /etc/resetlogs.cgi

So what does this mean? Very simple. In this example we have a crontab file that contains 2 commands. A crontab file can have any number of commands. You put one command per line so [ 0 * * * * * /etc/reset.cgi ] is COMMAND ONE and [ 0 0 * * * /etc/resetlogs.cgi ] is COMMAND TWO. I could have COMMAND THREE - COMMAND 2,000 if I wanted to but what is important is you only put ONE COMMAND PER LINE. Also EVEN MORE IMPORTANT after the LAST COMMAND you MUST HAVE A BLANK LINE or CRONTAB WILL NOT RUN.

Ok, so let's look at each command. Here is what we have - very simple just remember this is just like setting an alarm clock. Each line or COMMAND is SCHEDULED to run at a specific time. The first 5 fields deal with setting the time the command (second field) will run.

0 * * * * is the SCHEDULE for COMMAND ONE [ /etc/reset.cgi]

0 0 * * * is the SCHEDULE for COMMAND TWO [ /etc/resetlogs.cgi]

The way the schedule looks is very cryptic but its really very simple. There are FIVE fields to the SCHEDULE

MINUTE(0-59) HOUR(0-23) DAYOFMONTH(1-31) MONTHOFYEAR(1-12) DAYOFWEEK(0-6) Note 0 = Sun

Also note that the ASTERISK (*) is what's called a WILDCARD meaning it will match any value.

Now maybe its a little clearer: The first command of our example

0 * * * * /etc/reset.cgi

Means literally "execute the script located at /etc/reset.cgi whenever the clock is equal to 0 minutes on ANYDAY, ANY HOUR,ANY DAYOFMONTH,ANY DAYOFWEEK. So the script is set to run ONCE PER HOUR EXACTLY ON THE HOUR regardless of what day it is or what hour.


0 0 * * * /etc/resetlogs.cgi

is a little more picky. This crontab runs again whenever the internal clock hits ZERO (0) Minutes, but instead of running once per minute it will only run once per hour. WHY? Because we also set the HOUR to zero so BOTH the MINUTES and HOUR must be equal to zero before crontab will execute /etc/resetlogs.cgi. So this example runs once per DAY at MIDNIGHT server time.

Now, you can get even more picky, final example lets setup a crontab to run only on Tuesday at 2:21 PM.

So our crontab entry would be

21 14 * * 2 /path/to/whatever/script.cgi


It does not matter what you call your crontab file. You should name it something so you remember what the file is (eg: cronstats or croncgi) or whatever.

Upload as ASCII file (they are text files) all text files are ASCII

When you are done with all that telnet into your server and run the crontab file by going to the directory containing the crontab file (again - it makes no difference where you put the crontab file). I would suggest making a special hidden directory or using a directory inside your cgi-bin so nobody can see it. So to finish and execute your crontab file just telnet into your server and type:

  • cd /path/to/crontab/directory
  • crontab nameofcrontabfile