如何在我的bash脚本中运行ruby命令而不会出现“ruby:command not found”

时间:2010-09-28 15:31:21

标签: ruby bash

我的剧本=

#!/bin/bash

echo ************************BEGIN LOG******************************>>/root/backup_scripts/new_scripts/vmbackup.log 2>&1
date +"%m/%d/%Y %H:%M:%S $HOSTNAME">>/root/backup_scripts/new_scripts/vmbackup.log 2>&1
ruby /root/backup_scripts/new_scripts/aapxen01.rb>>/root/backup_scripts/new_scripts/vmbackup.log 2>&1
ruby /root/backup_scripts/new_scripts/apvdbs03.rb>>/root/backup_scripts/new_scripts/vmbackup.log 2>&1
ruby /root/backup_scripts/new_scripts/aapxen02.rb>>/root/backup_scripts/new_scripts/vmbackup.log 2>&1

echo end log entry>>/root/backup_scripts/new_scripts/vmbackup.log 2>&1

我的日志=

************************BEGIN LOG******************************
09/28/2010 11:10:01 aapsan01.boingoboingo.local
/root/backup_scripts/new_scripts/run.sh: line 5: ruby: command not found
/root/backup_scripts/new_scripts/run.sh: line 6: ruby: command not found
/root/backup_scripts/new_scripts/run.sh: line 7: ruby: command not found
end log entry

我的crontab来自:

PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=admins@boingoboingo.com
HOME=/
LD_LIBRARY_PATH=/usr/local/lib/
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7)  OR
#sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  *  command to be executed
05 01 * * * /root/backup_scripts/run_backups.sh
22 11 * * * /root/backup_scripts/new_scripts/run.sh

3 个答案:

答案 0 :(得分:1)

将ruby所在的目录放入PATH。 PATH=/usr/bin/:$PATH"; export PATH

答案 1 :(得分:0)

您需要指定解释器的绝对路径名,例如/usr/bin/ruby,或检查它为何没有出现在拥有crontab的用户的环境的$PATH中。

答案 2 :(得分:0)

您是否尝试过为ruby添加完整路径?

克里斯