0

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
2
  • 1
    This might seem like a dumb question, but do you have ruby installed? Commented Sep 28, 2010 at 15:36
  • It occurs to me that I should mention that I have this running from crontab. Commented Sep 28, 2010 at 15:37

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

5 Comments

You might also want to store this line in your .bashrc to avoid typing it each time you open up a terminal.
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.
Do I just add a line to the script like this? PATH=/usr/bin/ruby and put that under #!/bin/bash ?
@micha, you need to write it the way I did above: PATH=/usr/bin:$PATH;export PATH
And of course, it will depend where ruby is installed on your system - I have mine in /usr/bin.
0

Have you tried adding the full path for ruby?

Chris

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.