[英]crontab cannot run shell script with docker command?
I have a simple shell script to run a docker command below, which works just fine if I ran it manually.我有一个简单的 shell 脚本来运行下面的 docker 命令,如果我手动运行它就可以了。 However it didn't work if I ran it by cron.
但是,如果我通过 cron 运行它,它就不起作用。 I didn't see any logging in
/var/log/cron
.. And I tested cron by creating a simple script to touch a file, and it worked fine.我没有在
/var/log/cron
中看到任何日志记录。我通过创建一个简单的脚本来触摸文件来测试 cron,它运行良好。 Cron doesn't work with docker? Cron 不适用于 docker?
cat start.sh
#!/bin/bash
docker run --shm-size 2g --rm --net sitespeedio_default \
-v "$(pwd):/sitespeed.io" sitespeedio/sitespeed.io:24.6.0\
--pageCompleteWaitTime 30000 \
lex-login.js lex-view_call_call_only.js -n 1 \
--influxdb.host influxdb \
--influxdb.username $INFLUX_U \
--influxdb.password $INFLUX_P --spa --multi
crontab -l
2 * * * * /home/ec2-user/start.sh >/dev/null 2>&1
Update the crontab
content to:将
crontab
内容更新为:
2 * * * * /bin/bash /home/ec2-user/start.sh >/dev/null 2>&1
And then, make sure that the crontab
's user has the permission to run this script.然后,确保
crontab
的用户具有运行此脚本的权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.