Leif160519的blog Leif160519的blog

——————

目录
crontab简介
/  

crontab简介

本文摘自:https://blog.csdn.net/qq_39377418/article/details/89374673

image.png

root 身份登录到命令行

输入 crontab -e (注:不要输入 crontab -r 了,因为 e 和 r 挨着的,r 就是 remove )

按下 a 键进入到编辑模式

输入 0 */1 * * * cd /home/work; python3 test.py

或者 */60 * * * * cd /home/work; python3 test.py

同时按下 ctrl+c 退出编辑模式

同时按下 shift+q: 输入 wq 保存退出crontab

或者直接修改/etc/crontab文件,之后用crontab /etc/crontab生效

下面是每隔多少分钟,每隔多少小时,每天/每周/每月/每年的crontab的归纳总结

  • 每五分钟执行 */5 * * * *
  • 每五小时执行 0 */5 * * *
  • 每天执行 0 0 * * *
  • 每周执行 0 0 * * 0
  • 每月执行 0 0 1 * *
  • 每年执行 0 0 1 1 *

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题crontab简介
作  者Leif160519
出  处https://github.icu/articles/2019/09/10/1568082953718.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!