apt-get update
apt-get install cron
apt-get install vi
crontab -e # 打开定时任务编辑页面,增加如下内容
* * * * * /bin/date >> /tmp/tmp.txt
/usr/sbin/cron # 启动
等待一分钟左右,查看 /tmp/tmp.txt
参考: http://manpages.ubuntu.com/manpages/xenial/man8/cron.8.html
注意:不要使用 cron -f 来启动cron服务;定时任务里面的命令最好都用绝对路径;定时任务的输出要么定向到文件要么定向到空,防止磁盘被占满
Docker Ubuntu 内使用定时任务 cron
最新推荐文章于 2024-05-17 19:35:00 发布