Bundle exec无法与crontab一起使用 [英] bundle exec not working with crontab

查看:87
本文介绍了Bundle exec无法与crontab一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用crontab执行以下shell脚本:

I'm trying to execute the following shell script using crontab:

#!/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条目是

The crontab entry is

0 16 * * * /mnt/voylla-production/releases/20131031003111/voylla_scripts/cj_4pm.sh

我在邮件中收到以下错误消息:

I'm getting the following error message in the mail:

/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

手动运行命令时没有出现错误。不知道这是怎么回事。

I dont get the error when I run the commands manually. Not sure what's going on here. Could someone please point out.

谢谢

推荐答案

一个不错的技巧要在crontab中正确设置所有环境,请使用 / bin / bash -l <​​/ code>:

A nice trick to get all environment properly set up in crontab is to use /bin/bash -l :

0 16 * * * /bin/bash -l -c '/mnt/voylla-production/releases/20131031003111/voylla_scripts/cj_4pm.sh'

-l <​​/ code>选项将调用完整的登录Shell,从而读取您的bashrc文件和任何路径/ rvm设置它的性能。

The -l option will invoke a full login shell, thus reading your bashrc file and any path / rvm setting it performs.

如果您想简化crontab管理并使用此技巧(以及其他技巧)而不必考虑它们,则可以使用只要有宝石。如果您使用capistrano,它也可以很好地与capistrano配合使用,并在部署时重新生成crontab。

If you want to simplify your crontab management and use this trick - as well as others - without having to think about them, you can use the Whenever gem. It also play very nice with capistrano, if you use it, regenerating crontab on deploy.

这篇关于Bundle exec无法与crontab一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆