MyHosti - International hosting-center Help

Русский English
  • Дома
  • FAQ
  • Administration VDS/Server
  • Scheduler(Cron)
  • How to create a task to run in Cron?

Категории

  • Domain names
  • Shared/Reselling hosting
  • Administration VDS/Server
  • SSL certificates
  • Software
  • Other
How to create a task to run in Cron?

Cron is a task scheduler in Linux operating systems, and others. Is used to start/run jobs at a specific time.

For adding a command to Cron, use the command:

crontab -e

Example of adding a command

We need to run the script /var/www/user/data/www/site.ru/cron.php every five minutes.

We get the command php -f /var/www/user/data/www/site.ru/cron.php

Now we need to specify at what time to execute the script:

* * * * * the command being executed
- - - - -
| | | | |
| | | | ----- Day of the week (0 - 7)
| | | ------- Month(1 - 12)
| | --------- Day (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

* * * * * php -f /var/www/user/data/www/site.ru/cron.php - means that to run every minute, every hour, every day, every month, every week.

*/5 * * * * php -f /var/www/user/data/www/site.ru/cron.php - the command will run every 5 minutes.

5 * * * * php -f /var/www/user/data/www/site.ru/cron.php - the command will run every hour at 5 minutes.
0 1 * * * php -f /var/www/user/data/www/site.ru/cron.php - the command will run every day in the morning.

If you have the following error:

root@server:~# crontab -e -bash: crontab: command not found

This error means that Cron on your server is not installed. To install run the following command:

Debian/Ubuntu:

apt-get install cron

CentOS:

yum install cronie

The Cron logs are located in the following path:

Debian/Ubuntu:

/var/log/syslog

CentOS:

/var/log/cron
© MyHosti International, 2013-2020

International hosting center. "MyHosti" works only with the checked methods. In our interests development of your website and growth of its profitability. We watch our reputation and we always equal hopes which on us are laid.

Компания
  • About us
  • Blog
  • Shares
  • FAQ
  • Payment
  • Vacancy
  • Customer Support
Информация
  • Data-center
  • Service programs
  • Documents
  • Status network
  • Services
Поиск статей
€ $ ₽
Яндекс.Метрика
службы мониторинга серверов Uptime по данным Ping-Admin.Ru - сервиса мониторинга доступности сайтов
HostDB.ru - портал о хостинге и хостинг-провайдерах