我正在尝试使用 crontab 执行以下 shell 脚本:
#!/bin/sh
cd /mnt/voylla-production/current
bundle exec rake maintenance:last_2_days_orders
bundle exec rake maintenance:send_last_2_days_payment_dropouts
crontab 条目是
0 16 * * * /mnt/voylla-production/releases/20131031003111/voylla_scripts/cj_4pm.sh
我在邮件中收到以下错误消息:
/mnt/voylla-staging/current/voylla_scripts/cj_4pm.sh: line 3: bundle: command not found
/mnt/voylla-staging/current/voylla_scripts/cj_4pm.sh: line 4: bundle: command not found
当我手动运行命令时,我没有收到错误消息。不知道这里发生了什么。请问有人可以指点一下吗。
Thanks
在 crontab 中正确设置所有环境的一个好技巧是使用/bin/bash -l
:
0 16 * * * /bin/bash -l -c '/mnt/voylla-production/releases/20131031003111/voylla_scripts/cj_4pm.sh'
The -l
选项将调用完整的登录 shell,从而读取您的 bashrc 文件及其执行的任何路径/rvm 设置。
如果你想简化你的 crontab 管理并使用这个技巧 - 以及其他技巧 - 而不必考虑它们,你可以使用每当宝石。它也与 capistrano 配合得很好,如果你使用它,在部署时重新生成 crontab。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)