In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the CentOS7 implementation of PHP timing task method example, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
1. CentOS 7 install crontab:
Yum install crontabs
Syntax:
Crontab [- u] [configuration file] or crontab [- u] [- elr]
Parameters:
-e edit the timer settings for the user.
-l lists the timer settings for the user.
-r removes the timer setting for the user.
-u specifies the name of the user to set the timer.
For more information on how to use the Crontab command, please refer to this article: https://www.jb51.net/article/148575.htm
1. On the command line, enter:
Crontab-e
Then add the corresponding task, wq save and exit
2. Find the php execution directory:
Which php
3. Execute script format
* / usr/local/php/bin/php / var/www/aaa.php
4. Service status
Systemctl start crond.servicesystemctl stop crond.servicesystemctl restart crond.servicesystemctl reload crond.servicesystemctl enable crond.service # # set cron boot crontab-l # # View current croncrontab-e # # Edit current croncrontab-r # # Delete current cron
II. Practical examples
Parameter description
Minute: the minute of each hour to execute the task. Value range: 0-59.
Hour: the number of hours of the day to perform the task. Value range: 0-23.
Day: perform this task on the day of each month. Value range: 1-31.
Month: the month in which the task is performed, with a value range of 1-12
DayOfWeek: the day on which the task is performed each week. The value range is 0-6. 0 indicates the weekend.
CommandPath: specify the path of the program to be executed
3021 * / etc/init.d/nginx restart # # restart nginx at 21:30 every night. Restart nginx at 4: 45 on the 1st, 10th and 22nd of each month at 4: 45 etc/init.d/nginx restart. 10 1 * * 6 nginx / etc/init.d/nginx restart # # restart nginx every Saturday and Sunday at 1: 10. 0pr 30 18-23 * / etc/init.d/nginx restart # # restart nginx every 30 minutes between 18: 00 and 23: 00 every day. 023 * * 6 / etc/init.d/nginx restart # # restart nginx every Saturday at 11: 00 pm. * * / 1 * / etc/init.d/nginx restart # # restart nginx* 23-7 etc/init.d/nginx restart 1 * / etc/init.d/nginx restart # # every hour between 11:00 and 7am Restart nginx0 11 4 * mon-wed / etc/init.d/nginx restart # # every other hour and restart nginx0 4 1 jan * / etc/init.d/nginx restart # # at 11:00 every Monday to Wednesday. Restart nginx*/30 * / usr/sbin/ntpdate 210.72.145.20 # # every half hour. Thank you for reading this article carefully. I hope the article "how CentOS7 performs PHP scheduled tasks" shared by the editor is helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.