您的位置:首页 > 运维架构 > Linux

Centos7 上 用crontab 实现php计划任务

2018-03-02 13:19 274 查看

Centos7 上 用crontab 实现php计划任务

原创 2017年04月17日 22:44:261790

首先用命令检查服务是否在运行

systemctl status crond.service
1

如果服务器上没有装有crontab ,则可以执行

yum install vixie-cron
yum install crontabs
1
2

常用指令

systemctl restart crond.service #启动服务

systemctl reload crond.service #重新载入配置

systemctl status crond.service #查看crontab服务状态

systemctl enable crond.service #开机自启动
1
2
3
4
5
6
7

启动服务之后可以输入指令

crontab -e #进入定时任务编辑
1

相关参数

基本格式 :  
* *   *  *  *  command  
分  时  日  月  周  命令  
第1列表示分钟1~59 每分钟用*或者 */1表示  
第2列表示小时1~23(0表示0点)  
第3列表示日期1~31  
第4列表示月份1~12  
第5列标识号星期0~6(0表示星期天)  
第6列要运行的命令
1
2
3
4
5
6
7
8
9

例子

*/2 * * * * curl -o /home/index.html www.baidu.com #每隔两分钟使用curl 访问www.baidu.com 并将结果写入/home/index.html 文件
1
将后面的指令换成服务器php需要定时循环的任务接口即可
参考:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: