Frequently Asked Questions

Return to the list of Frequently Asked Questions

How do I setup or create a Cron Job?

You'd firstly need to know what job you'd actually like to run. What I normally do is write a php file that would do some task and then upload it into a password protected section of the website. I'm going to write the answer to this question according to that situation, but bear in mind that you can set up a Cron Job for any executable command that you can dream of.

Log into your CPanel and click on Cron Jobs, then click on Advanced (Unix Style). Note: The people who created Cpanel thought that setting up a Cron Job is only for advanced users - it isnt, its pretty simple actually.

You'll be presented with something that is referred to in technical terms as a Crontab. In normal people's language, Crontab is simply the list of jobs that the Cron Daemon has to do. The Cron Daemon program "wakes up" every minute and goes through the list, checking if there's anything that it should do. Again the Cpanel programmers have made a nice interactive interface for setting up your Cron Jobs ... my hat goes off to them, but if you're not using Cpanel then a simple text editor can do the job just as well.

The Crontab Has 5 small text areas, used for specifying a time and then a larger area to specify the command. The time to run the command is specified in the following order:


and you may only enter valid numbers.
So if you wanted to run the command "Some job" at 30 minutes past 12 every day, then your Crontab should look like this.

3012***Some Job

The * is a wildcard and should be read as "Every" or "Any". So reading the time part, you'd end up with: "30 minutes past the 12th hour, every day, every month, any day of the week". Tip: Be careful with those *'s as you can end up doing things more often than you've intended.

If you wanted to run a command every Second hour during the month of June you'd set up your Crontab as follows:

0*/2*6*Some Command

Which is read as follows:
"Every 0 minutes past, Every 2nd Hour, Every Day, on the 6th Month (June), Any day of the week".

There's no limit to the number of commands you can add to the Crontab, so you can do one Job on the hour at 10am on the 3rd of the month every month and another twice a day on Sundays like this:

0103**Job #1
0*/12**1Job #2

Return to the list of FAQs