The cron job scheduler can be configured in the server control panel:
Also, you can configure scheduled tasks via SSH.
To view existing cron jobs, enter the command:
To edit the list of tasks, open the cron editor with the following command:
An editor will open in which you can specify the necessary tasks.
Each task starts on a new line. First, the frequency of launch is indicated, and then the task itself.
At the end of the last command entered, press Enter to linefeed and save the changes:
- F2 - save changes,
- F10 - exit the editor (you will need to confirm or discard changes).
If all the data in the editor was entered correctly, the terminal will display the following output:
crontab: installing new crontab
Frequency of the assignment
To indicate the frequency of the task, the following five fields are used, located on the left side of the task line:
- minutes (from 0 to 59),
- hours: (from 0 to 23),
- days (from 0 to 31),
- months (from 0 to 12),
- days of the week: (from 0 to 6, 0 - Sunday).
* - any parameter value is applicable.
1,2,4 - execution of the task during the specified periods,
1-4 - execution of the task in the periods in this interval.
Let's give an example of setting the frequency of tasks execution using the example of days of the month:
- * - everyday;
- */n - every n days;
- n - with the beginning of the n-th day;
- a, b, c - with the beginning of the specified days.
Examples of the frequency of tasks execution for all time parameters:
- 0/40 * * * * - every 40 minutes;
- 0 9.17 * * 2 - at 9 and 17 hours every Monday;
- 0 12 18 * * - at 12 noon on the 18th day of each month;
- 0 */4 * * 3 - every 4 hours on Tuesdays;
- 0 5 * * 2 - every Monday at 5:00.
For diagnostics of executed scripts, it is recommended to enable sending errors to the administrator's email (specified in the MAILTO line when connecting via SSH).
Notes on working with cron
1. To select the PHP version when starting the script, specify the path to the interpreter:
where XX is the required version, can be specified with or without a point (XX or X.X).
For example, to run script.php from PHP 5.6, enter:
user – login,
u - first letter of login.
2. Running a script that requires web server variables directly through the PHP interpreter can lead to errors.
If you have any questions, please create a ticket to technical support.