tags:

views:

53

answers:

3

my script=

#!/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

my log=

************************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

my crontab this runs from:

PATH=/sbin:/bin:/usr/sbin:/usr/bin
[email protected]
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
A: 

You need to specify the absolute pathname of the interpreter e.g. /usr/bin/ruby, or check why it does not appear in the environment of the calling user.

philippe
A: 

Hi,

Have you tried adding the full path for ruby?

Chris

Chris McCauley
+1  A: 

Put the directory that ruby lives in into your PATH. PATH=/usr/bin/:$PATH"; export PATH

Paul Tomblin
You might also want to store this line in your `.bashrc` to avoid typing it each time you open up a terminal.
André Caron
If the script is run from cron or some other background method, it won't inherit your PATH, so you need to make sure the PATH is set in the script.
Paul Tomblin
Do I just add a line to the script like this? PATH=/usr/bin/ruby and put that under #!/bin/bash ?
Captain Claptrap
@micha, you need to write it the way I did above: `PATH=/usr/bin:$PATH;export PATH`
Paul Tomblin
And of course, it will depend where ruby is installed on your system - I have mine in /usr/bin.
Paul Tomblin
Thanks for the follow through. That worked!
Captain Claptrap