🔑 Авторизоваться

Rules for creating scheduler tasks

A cron job consists of six columns separated by spaces or tabs. The first five columns specify the execution time (Minute, Hour, Day, Month, Day of Week). They can contain a number, a comma-separated list of numbers, or a range of numbers separated by a dash ( - ) or an asterisk ( * ) . All other characters in the line are interpreted as the command being executed and its parameters.


For each specific parameter, you can specify multiple values separated by commas.
For example, if you write 1,4,22 in the hours field, the task will be launched at 1 am, 4 am and 10 pm.
You can set an interval - 4-9 will mean that the program should be launched every hour in the period from 4 to 9 o'clock inclusive.
The * symbol means "all possible values." For example, entering * in the hours field would mean "run every hour."
The / symbol is used to specify additional task frequency. For example, */3 in the hours field means "every three hours."

Recommendation

If you need to run a program once a day, especially if it requires large resources, perform this task at night, between 2 a.m. and 8 a.m. - the load on the server is minimal at this time.

What does the simplest scheduler (cron) script look like:

The script located at /home/login/html/cron.php will automatically run every three hours on Tuesday and Friday.

Examples of using tasks:

Perform the task once per hour at 0 minutes


Perform the task every three hours at 0 minutes


Complete the task on Mondays at 1:15 am


Complete the task on April 5 at 0:01 every year


Complete the task on Friday, the 13th, at 1:13 pm


Complete the task monthly on the 1st at 6:10 am


The examples above illustrate running scripts within the hosting service. If you need to run scripts through the website's domain, for example , htpp://domain.ru/cron.php , then you need to use wget instead of /usr/local/bin/php .

Example:

Perform the task once per hour at 0 minutes


How to check whether Cron is running at all is described on the page Checking the scheduler's operation .