The section CronTab (tasks on schedule) serves for adjustment of command performance on schedule and at set times. With CronTab you can set a concrete time and the command will be performed at this exact time. The CronTab can be configured in such a way that the task will be performed once a month, a day, an hour, every minute or for instance every 10 minutes. Also you can combine the settings. For instance if you want the command to be performed once an hour within the first 2 hours, but not to be performed at all within the following 2 hours.
Let's begin our acquaintance with Cron by opening the Task wizard. With the help of the wizard the script performance time can be adjusted without any serious administration knowledge, simply by selecting certain combinations from drop down lists. You also need to indicate the script path or the command that shall be performed in Cron.
Let's review an example of running a script, written in PERL language, that shall be run every 5 minutes.
Upon pressing the button , a new record with your first configuration will appear beneath the main Cron window. The number of these records is not limited.
Now we have the first task that we can activatedeactivate, edit or delete with help of the buttons on the right of each task.
- activate/deactivate task;
- edit task;
- delete task.
Manual CronTab setup.
This section also contains a manual setup option allowing to adjust the script performance time in a way well known to those familiar with Cron.
Minutes can range from 0 to 59
Hours can range from 0 to 23
The day of a month can range from 1 to 31
A month can range from 1 to 12
A weekday can range from 0 to 7, where 0 and 7 equals Sunday
Configuration of CronTab for task completion is not only available at a certain
time, but every minute, hourly, daily, weekly and monthly,
using the combination */x.
*/5 * * * * - perform command every five minutes
0 */3 * * * - perform every three hours
0 12-16 * * * - perform command once an hour from 12 to 16 (12, 13, 14, 15, 16)
0 12,16,18 * * * - perform command once an hour at 12, 16 and 18
*/1 * * * * /usr/bin/php ~/site.ru/public_html/test.php - perform php-script test.php minute-by-minute
0 */1 * * * /usr/bin/perl ~/site.ru/public_html/test.pl - hourly activation of perl-script test.pl
A path from the home directory to the script needs to be created
For example: public_html/cgi-bin/script.pl
The system will insert the character ~/ automatically (this combination replaces the full path).
We will receive: ~/public_html/cgi-bin/script.pl
If the character & (ampersand) is inserted at the end of the path, the script will work in background mode.
Setting this character is not obligatory.
In some cases that need you to choose PHP version, you should use /usr/local/bin/phpX.X or /usr/local/php-cgi/X.X/bin/php-script (replace X.X for PHP version you need to use: 7.0, 7.1, etc). The PHP version selecting option in Control panel does not affect on PHP running from Crontab.
PHP directives should be specifed separately with a -d flag for each directive: /usr/local/bin/php5.6 -d display_errors=1 script.php