ubuntu Docker 环境下设置crontab
设置crontab 第一个问题就是时区不对的问题,默认系统时区为UTC,时间不同步,设置定时任务时会有偏差。因此,先更改时区
解决办法:在Dockerfile中加入即可
RUN echo”Asia/Shanghai” > /etc/timezone RUN dpkg-reconfigure -f noninteractive tzdata
容器启动之后,设置了crontab,结果一直不生效,后发现crontab 服务没有启动,于是网上各种搜索,发现了如下命令
ubuntu下定时执行工具cron开启关闭重启 配置文件一般为/etc/init.d/cron 启动:sudo /etc/init.d/cron start 关闭:sudo /etc/init.d/cron stop 重启:sudo /etc/init.d/cron restart 重新载入配置:sudo /etc/init.d/cron reload
运行遇到了问题
Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service cron start Since the script you are attempting to invoke has been converted to an Upstart job, you may also use the start(8) utility, e.g. start cron
尝试了提到的命令start cron /status cron,均报错。后搜索发现启动其实非常简单直接执行cron即可!
原文出处:csdn -> https://blog.csdn.net/marywang56/article/details/80773306
本站所发布的一切资源仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如果侵犯你的利益,请发送邮箱到 [email protected],我们会很快的为您处理。