在本地服務器上(ubuntu)我已經安裝了程序foodsoft,它是用ruby編寫的。它也使用bundler,mysql。 foodsoft可以通過在命令cronjob不能正確執行腳本
RAILS_ENV=production bundle exec rails s -b 192.168.0.15
我也有一個程序性sh腳本,開始foodsoft啓動,如果它不運行:
#!/bin/sh
export DISPLAY=:0
export LANG=de_DE.utf8
ip_adr=$(/bin/hostname -I)
if [ $(pidof ruby) ]
then
echo "online"
else
echo "offline"
cd /home/jondal/foodsoft
RAILS_ENV=production bundle exec rails s -b $ip_adr
fi
如果我在shell中運行腳本,所有工作正常。但是我的cronjob(列在crontab中)並沒有完全執行腳本。它產生以下txt文件:
離線 在/ usr/local/bin目錄/包:
offline bundler: command not found: rails Install missing gem executables with `bundle install`
如果我與前綴ENV -i我碰到下面的shell啓動的sh腳本:23:在
load': cannot load such file -- /usr/share/rubygems-integration/1.9.1/gems/bundler-1.3.5/bin/bundle (LoadError) from /usr/local/bin/bundle:23:in
'
你有什麼想法我可以做什麼?
您使用的是rvm嗎?您可能需要採取一些額外步驟,以使rvm與crontab配合使用。 –
你的'cron'用戶在'/ home/jondal/foodsoft'目錄中有權限嗎?具體來說,執行權限是否正確,特別是在'bin /'中? –