

Setting up cron
1. First of all you need to decide which program you want to run and get its full path at the server disk. The path can look like: /your_directory/whatever.pl.
3. Write the schedule for your task in such a way that cron tab will understand it.
The basic format of a crontab schedule consists of 6 fields, separated by spaces, formatted as follows:
The acceptable values for each of the 6 fields are:
Field | Range of values |
---|---|
minute | 0-59 |
hour | 0-23 |
day | 1-31 |
month | 1-12 |
day-of-week | 0-7 (where both 0 and 7 mean Sun, 1 = Mon, 2 = Tue, etc) |
command-line-to-execute | the path to the program you want to run |
The fields have to be in that exact order, with no empty or missing fields.
- If needed you can use a wildcard character - "*" (the asterisk). In a crontab file it represents every possible value for the field. For example, specifying :*" in the "hour" means "to run every hour."
- '/' character is used to specify additional frequency assignments. For example, '* / 3' in the "hour" means "every three hours."
- For each individual parameter, you can specify multiple values separated by commas. For example, if in the "hour" you type 1,6,19, the job will run at 1:00 am, at 6:00 am and 19 hours. You can also specify the interval, for example, 8-17 would mean that the program will be run every hour from 8 to 17 inclusive.
So, for example, your command line can look like this:
And in this case it means that the /your_directory/whatever.pl. program will be run every 3 hours.
If you want to run PHP-scripts with the stated period, you can do that with a help of wget. For that the command-line-to-execute should look like the next example:
To save and exit type :q and press Enter.
Congratulations! You have now scheduled your tasks.
Related articles:
- PaaS vs IaaS? Combine them instead! (jelastic.com)
- Run Java Console Applications in the Cloud (jelastic.com)