centos添加定时任务

安装crontab:

yum install crontabs

查看crontab服务状态:service crond status

手动启动crontab服务:service crond start

查看crontab服务是否已设置为开机启动,执行命令:chkconfig --list

如果没有加入开机启动:chkconfig crond on

添加一条定时任务:crontab -e进入编辑器

*/3 * * * * /usr/bin/curl http://127.0.0.1/charge/index.php/Admin/Cron/login

表示每3分钟执行一次这个路径,可以在login方法写日志看效果

可以查看下curl位置,find / -name 'curl'

重启crond服务

service crond restart

在终端直接运行下那个路径试一下看对不对

curl http://127.0.0.1/charge/index.php/Admin/Cron/login

这样就可以了,具体定时任务的其他用法参考网上

查看所有定时任务:crontab -l

删除所有定时任务:crontab -r

posted @ 2017-06-21 15:26  屌丝IT男  阅读(389)  评论(0编辑  收藏  举报