Cron is a scheduled execution tool under Linux, which can run jobs without human intervention. It is a built-in service of Linux, so we will use it in many cases.
First of all, how to enable/disable the service
//Start Service sudo service cron start //Stop service sudo service cron stop //Restart service sudo service cron restart //Reload configuration sudo service cron reload
Most of the VPS planning tasks have been added to the startup and auto start by default, but some VPS (such as tile removal workers) have not added them to the startup and auto start. If we want to use Cron, we must make it start automatically, otherwise it would be ridiculous to have to manually pull it up every time.
It is also simple to add it to the boot auto start method. Add/sbin/service crond start or sudo service cron start directly to/etc/rc.d/rc.local
Then edit the scheduled task
Use the crontab - e command to edit the configuration of the scheduled task
Cron configuration file format:
"*" represents the number within the value range
"/" represents "every"
"-" means from a certain number to a certain number
Separate several discrete numbers
Here are some examples:
* 03 * * * sys/bin/reboot //Restart at 3:00 every morning */1 * * * * /usr/local/php/bin/php /home/www/test/do.php //Execute once every 1 minute * * * do.php */1 8-12 * * * /usr/local/php/bin/php /home/www/test/do.php //Execute every minute from 8:00 to 12:00 every day * * * do.php 30 9,12,17 * * * /usr/local/php/bin/php /home/www/test/do.php //Execute once every day at 9:30,12:30,17:30 * * * do.php
After modifying the file, wq saves and exits. Then use sudo service cron reload to reload the configuration of the scheduled task
This article is published at: yingfeng Blog >> Use of Cron Scheduled Tasks , please indicate the source for reprinting.