2013-02-05 179 views
0

我有,如果它沒有運行啓動乘客實例的shell腳本:shell腳本啓動乘客

#!/bin/bash 
/usr/sbin/lsof -i :82 > /home/var/www/site-owner/data/www/site.com/currenttest 
if [ ! -s /home/var/www/site-owner/data/www/site.com/currenttest ]; 
    then 
    cd /home/var/www/site-owner/data/www/site.com/current/ 
    passenger start -p 82 -d -e production --user site-owner 
fi 

,如果我從根SSH環境中啓動它的作品非常好。 我試圖從crontab啓動它,它沒有以錯誤開始:「passenger_loader.sh:line 12:passenger:command not found」。

經過多個小時的谷歌搜索,我發現從root用戶和根控制檯用戶有crontab有不同的環境,但無論如何,我不明白如何使一個crontab root用戶運行腳本根控制檯用戶腳本。我開始添加

source ~/.bash_profile 
source ~/.bashrc 

一個腳本,但它沒有改變任何東西。

+1

嘗試使用絕對路徑'passenger' – nameless

+0

無名,我試過這個 - 錯誤更改爲「/ usr/bin/env:ruby_noexec_wrapper:沒有這樣的文件或目錄」 –

回答

0

我dont't知道,如果它是一個解決方案,但它就像我需要(我開始從bash)的:

#!/bin/bash 

if [ -f ~/.bashrc ]; then 
    . ~/.bashrc 
fi 

HOME=/root 
PATH=/usr/local/rvm/gems/ruby-1.9.3-p374/bin:/usr/local/rvm/gems/[email protected]/bin:/usr/local/rvm/rubies/ruby-1.9.3-p374/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin 
export HOME PATH 

/usr/sbin/lsof -i :82 > /home/var/www/site-owner/data/www/site.com/currenttest 
if [ ! -s /home/var/www/site-owner/data/www/site.com/currenttest ]; 
    then 
    # passenger down 
    date 
    #. "/usr/local/rvm/scripts/rvm" 
    rvm use 1.9.3 
    cd /home/var/www/site-owner/data/www/site.com/current/ 
    passenger start -p 82 -d -e production --user site-owner 
fi