How do CentOS7 perform PHP timed task detail
- 2020-12-16 06:16:00
- OfStack
preface
This article mainly introduces the CentOS7 to perform PHP timing task related content, sharing for your reference and study, the following words do not say much, let's have a look at the detailed introduction
CentOS 7 Installation crontab:
yum install crontabs
Grammar:
crontab [-u < The user name > ][configuration file] or crontab [-ES18en] < The user name > ][-elr]
Parameters:
The use of more about Crontab command method can refer to this article: https: / / www ofstack. com article / 148575. htm
1, in the command line input:
crontab -e
Then add the corresponding task, wq disk exit;
2. Find the php execution directory:
which php
3. Execute the script format
* * * * * /usr/local/php/bin/php /var/www/aaa.php
4. Service status
systemctl start crond.service
systemctl stop crond.service
systemctl restart crond.service
systemctl reload crond.service
systemctl enable crond.service ## Set up the cron Powered up
crontab -l ## View the current cron
crontab -e ## Edit the current cron
crontab -r ## Delete the current cron
2. Practical examples
Parameters that
30 21 * * * /etc/init.d/nginx restart ## Every night, 21:30 restart nginx .
45 4 1,10,22 * * /etc/init.d/nginx restart ## A month 1 , 10 , 22 Day, 4 : 45 restart nginx .
10 1 * * 6,0 /etc/init.d/nginx restart ## Once a week 6. Sunday's 1 : 10 restart nginx .
0,30 18-23 * * * /etc/init.d/nginx restart ## Every day, 18 : 00 to 23 : 00 Between every 30 Minutes to restart nginx .
0 23 * * 6 /etc/init.d/nginx restart ## Every week 6 the 11 : 00 pm restart nginx .
* */1 * * * /etc/init.d/nginx restart ## every 1 Hours to restart nginx
* 23-7/1 * * * /etc/init.d/nginx restart ## evening 11 Point to the morning 7 Between the dots, each every 1 Hours to restart nginx
0 11 4 * mon-wed /etc/init.d/nginx restart ## The monthly 4 With the weekly 1 To the week 3 the 11 Point to restart nginx
0 4 1 jan * /etc/init.d/nginx restart ##1 month 1 The no. 4 Point to restart nginx
*/30 * * * * /usr/sbin/ntpdate 210.72.145.20 ## Synchronize every half an hour 1 Next time
conclusion