Linux 设置定时任务
Linux 设置定时任务
1. 安装 crontab
yum -y install crontabs
2. 开启 crontab 服务
service crond start
service crond start #启动服务
service crond stop #关闭服务
service crond restart #重启服务
service crond reload #重新载入配置
# 查看crontab服务状态
service crond status
3.设置服务是否开机自启动
systemctl list-unit-files | grep crond
如果显示 crond.service disabled
则不是开机自启动的,所以需要设置:
systemctl enable crond.service
systemctl list-unit-files | grep crond
crond.service enabled
结果如上就设置好了。
4. 设置需要执行的脚本
crontab -e
按上面的格式编辑文本,如:
0 2 * * * /root/test.sh
表示在每天2点执行 root 目录下的 test.sh 脚本。
AD:
【腾讯云服务器大降价】
2核4G 222元/3年 1核2G 38元/年
网站:阿蛮君博客
标题:Linux 设置定时任务
链接:https://www.amjun.com/397.html
本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长进行核实删除。
转载本站文章需要遵守:商业转载请联系站长,非商业转载请注明出处!!
标题:Linux 设置定时任务
链接:https://www.amjun.com/397.html
本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长进行核实删除。
转载本站文章需要遵守:商业转载请联系站长,非商业转载请注明出处!!
THE END
点赞 0
二维码
打赏
海报


Linux 设置定时任务
Linux 设置定时任务
1. 安装 crontab
yum -y install crontabs
2. 开启 crontab 服务
service crond start
service crond start #启动服务
service crond sto……

共有 0 条评论