大家好我只是有dockerized除了我的cron作業我的整個應用程序,這裏是我dockerFile泊塢窗的Node.js的Cron
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世界它工作正常,但是當我有節點cron在那裏它似乎沒有做任何事情。如果我進入容器並執行crontab -e並手動添加它,它可以正常工作。
任何想法我做錯了什麼?
感謝
你在/var/log/cron.log中看到有什麼可疑的東西嗎? –
其空。還有什麼我應該看看? – MrB