PHP commonly used Linux the system executes tasks regularly Cron and Crontab introduce

during the website construction process, many applications need to use timing tasks, such as timed backup, timed crawling, timed update data, restarting the server, etc. these require timing tasks. Windows the system has a planned task. Linux most people pass Cron finish. below, suyou network introduces you to the magic of this timed task.
Cron what can be done?
cron yes Linux a program that allows the system to perform a specified work at a specified time, using crontab instructions to manage cron。
how to edit crontab?
crontab -u //set a user's cron service, general root the user needs this parameter when executing this command
crontab -l //list a user cron details of the service
crontab -r //delete no user cron serve
crontab -e //edit a user's cron service, the most commonly used
many people are not familiar with it Linux how to release the instructions after editing? according to Esc then enter: wq save it, if it is used root log in, the record file will be saved in /var/spool/cron/table of contents root files can be modified directly.
Crontab instruction format
* * * * * order
the first five *parameters refer to time
the first minute(point )can set 0-59 points
the second one hour( hours) can be set to 0-23 hours
third day of month( date) can be set to number 1-31
the fourth month( month): can be set from january to december
the fifth day of week( week): you can set the day of the week 0-7, where 0 and 7 represent sunday, or we can also use names to represent sunday to monday, e.g. sun it means sunday, mon mean monday and so on
commonly used Crontaborder
perform every five minutes */5 * * * *
performed every hour 0 * * * *
performed every day 0 0 * * *
performed every week 0 0 * * 0
monthly execution 0 0 1 * *
performed annually 0 0 1 1 *
how to install crontab
yum install crontabs
common startup and shutdown commands
/sbin/service crond start //start the service
/sbin/service crond stop //close service
/sbin/service crond restart //restart the service
/sbin/service crond reload //reload the configuration
service crond status //check crontab service status:
service crond start //manual start crontab serve:
ntsysv //check crontab is the service set to boot
chkconfig –level 35 crond on //add to boot automatically
* 23-7/1 * * * /etc/init.d/nginx restart //restart every hour between 11pm and 7am nginx
0 11 4 * mon-wed /etc/init.d/nginx restart //restart on the 4th of each month and 11:00 every monday to wednesday nginx
0 4 1 jan * /etc/init.d/nginx restart // restart at 4:00 on january 1st nginx
*/30 * * * * /usr/sbin/ntpdate 210.72.145.20 //synchronize time every half hour
crontab implement PHP script
both of the following are ok
*/1 * * * * /usr/local/php/bin/php test.php
0 * * * * /usr/bin/wget -q website /Index/dingshi
as a PHP programmer, it is very necessary to understand this tool, and i hope it will be helpful to everyone.

the above is shared by suyou.com with everyone." PHP commonly used Linux the system executes tasks regularly Cron and Crontab introduction", thank you very much for your patience to finish this article. we will provide you with more information on reference, use or learning and communication. we can also provide you with:enterprise website construction, website imitation, website copying, imitation site, foreign trade website construction, foreign trade website construction, company official website productionfor services, our company serves customers with the service concept of "integrity, professionalism, pragmatism and innovation". if you need cooperation, please scan the code to consult, and we will serve you sincerely.
TAG label: