linux+php(定时任务)

crontab  -e 编辑crontab服务文件

*/1 * * * * php /var/www/html/index.php

cron服务是Linux的内置服务,但它不会开机自动启动。可以用以下命令启动和停止服务:

/sbin/service crond start
/sbin/service crond stop
/sbin/service crond restart
/sbin/service crond reload

以上1-4行分别为启动、停止、重启服务和重新加载配置。

要把cron设为在开机的时候自动启动,在 /etc/rc.d/rc.local 脚本中加入 /sbin/service crond start 即可

查看当前用户的crontab,输入 crontab -l;

编辑crontab,输入 crontab -e;

删除crontab,输入 crontab -r

#每隔1个小时执行一次  ls
0 */1 * * * ls
#每隔2个小时执行一次 ls
0 */2 * * * ls
#每隔3个小时执行一次 ls
0 */3 * * * ls
#每隔4个小时执行一次 ls
0 */4 * * * ls
#每隔10天执行一次 ls
0 0 */10 * * ls
#每天1点执行 ls
0 1 * * * ls

保存退出就行了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值