Automating Functions with cron Jobs
Think of cronas being short for chronology,and it will help you see that it is for jobs that
are performed automatically on a fixed time
schedule by theserver’s internal clock.
It’s like setting the timer to switch the heating on
before you get up in the morning or setting your
DVR to record the sameshow every week.
The command for a cron job basically has two parts:
✓ The command that the server should run:This means giving it the full
path to the file that you need to run and any switches that are needed to
perform the function. The software you run on your website should provide the correct switches to include.
✓ The exact time and schedule on which the job should be executed:
There is huge flexibility built into this system, meaning you can schedule
the task to run exactly when you want on whatever schedule you want.
cPanel provides an easy configuration screen for cron jobs. Here’s how to
use it:
1. Open cPanel and log in using the details your host gave you when you
signed up.
2. Scroll to the Advanced section and click Cron Jobs.
3. If you want to be e-mailed every time any cron job runs, enter your
e-mail address in the first box and click Update Email.
4. Select the schedule on which you wish the command to run.
There are some common settings to select from, or you can create your
own schedule.
You must fill every box when setting the schedule; otherwise the cron
job creation will fail.
5. Enter the command you want the server to run into the Command box.
You must add the full server path to the file you want to run in the cron
job. The server cannot guess which folder the file might be in!
6. Click Add New Cron Job to create the job and add it to the cron.