【发布时间】:2015-12-16 05:48:42
【问题描述】:
大家好,我只是将我的整个应用程序 dockerized,除了我的 cron 作业,这里是我的 dockerFile
FROM nodesource/precise
# Update install os dep
RUN apt-get update && apt-get install -y apt-utils cron
RUN apt-get -y install pwgen python-setuptools curl git unzip vim
# Add code
RUN mkdir /var/sites
ADD /api /var/sites/api
ADD /services /var/sites/services
RUN cd /var/sites/services && npm install
RUN cd /var/sites/api && npm install
# Add crontab file in the cron directory
ADD crontab /etc/cron.d/hello-cron
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/hello-cron
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Run the command on container startup
CMD cron && tail -f /var/log/cron.log
我的 cron 文件
* * * * * root echo "Hello world" >> /var/log/cron.log 2>&1
* * * * * cd /var/sites/services/ldapSync && node index.js >> 2>&1
# An empty line is required at the end of this file for a valid cron file.
如果我删除节点 cron 作业,只需离开 hello world,它就可以正常工作,但是当我在那里有节点 cron 时,它似乎没有做任何事情。如果我进入容器并执行 crontab -e 并手动添加它就可以了。
任何想法我做错了什么?
谢谢
【问题讨论】:
-
你在 /var/log/cron.log 中看到了什么可疑的东西吗?
-
它是空的。还有什么我应该看的吗?