I want to run a ruby script with crontab, here the bash script:
give this error:
when lauche manually its everything ok ....
This question is marked "community wiki".
asked 18 Sep '13, 05:15 ApeBox |
Hello, You need to remember that commands launched from 'cron' have a completely blank environment (so things like $PATH will be undefined). Also, you can't assume what your current working directory is, so things like $PWD probably won't work as expected. I suggest that you use absolute paths for ALL values in your script. Also, check this out for a super elegant way to debug these types of situations: http://benohead.com/linux-simulate-the-cron-environment-to-test-run-your-scripts/ Let me know if you have further questions. ~Christopher S, WebFaction Support answered 18 Sep '13, 12:55 likebike After further investigation seems the problem it's not crontab, even when launched directly the error pop up. start.sh:
launched with
return " (LoadError)in/ruby1.9: No such file or directory -- /home/{username}/watchdog-ruby/rdog.rb" while doing it manually (setting up the env) run smoothly .... what i am missing ?
(19 Sep '13, 03:33)
ApeBox
This is gettin weird... even a simple:
is givin
but
show that $HOME is correct ... i am really not understanding what is happening !
(19 Sep '13, 03:57)
ApeBox
|
One support guy helped me finding the problem: LINE ENDINGS ... i was using Putty from a Windows and didn't realize this was a problem. They converted the shell script with dos2unix and everything went right !
permanent link
This answer is marked "community wiki".
answered 19 Sep '13, 04:15 ApeBox |