docker - 为什么我的 Docker 容器没有运行我的 cron 脚本,但是当我重新启动服务 cron 时它运行了?
问题描述
当我进入我的容器时,Cron 不是一个正在运行的进程,但是当进入容器并 bashservice cron restart
它开始运行时,我不明白为什么这不能与 the 一起使用service cron restart
但不是没有它?
Dockerfile
FROM ubuntu:bionic
RUN apt-get update && apt-get -y install \
cron \
nano \
psmisc \
wget
COPY hello-cron /etc/cron.d/hello-cron
# Give execution rights on the cron job
RUN chmod +x /etc/cron.d/hello-cron
# Apply cron job
RUN crontab /etc/cron.d/hello-cron
# Create the log file to be able to run tail
CMD ["cron", "-f"]
我的 hello-cron 脚本
* * * * * echo "Hello world" > /usr/src/helloworldcron.log 2>&1
解决方案
推荐阅读
- javascript - 如何编写Active Element事件是Jquery
- javascript - 使用无序列表隐藏和显示 div
- javascript - 函数参数不适用于 .classList.add
- git - 在 HEAD 未指向最后一个提交时向 git 添加提交(提示)
- c++ - 检查统一数据的最佳方法是什么?
- python - 如何让 QFrame 更新其内容而无需在 QFrame 区域上单击鼠标?
- python - 有没有办法使用 Python csv 阅读器模块提取一些列?
- vue.js - 验证 vue html/template 中的脚本引用
- ios - 键盘打开时如何固定小部件布局?
- node.js - Twitter 无法读取 SSR vue.js 应用程序上的元标记