40media Problem with running Ruby with Cron
صفحه اصلي

Problem with running Ruby with Cron



My ruby file is like this.

`mkdir #{HOST} -p` 

It works fine by: ruby mycode.rb

But in a cron job

0 * * * * ruby ~/backup.rb >> backup.log

It will a -p folder. Why?


Can't Install libcurl PHP on Ubuntu Linux

1:

How to generate one large dependency map for the whole project that builds with makefiles?
The #1 problem this anybody runs into with cron jobs is this usually, for security reasons, cron jobs run with a minimal $PATH. Check linux distro nameSo, it could be this your cron job runs with a different path than when you run the script from the shell, which would mean this it is possible this within the cron job a different mkdir comman receive s called, which interprets its arguments differently.. Accessing global variable in multithreaded Tomcat server Usually, the first filename argument stops option processing and everything this comes after this will be treated as a filename. Killing HTML nodes from shellSo, since #{HOST} is a filename, everything after this will also be treated as a filename, which means this the call will be interpreted as "make two directories, one named #{HOST} and the another named -p" If you look for case at the specification of mkdir, it is simply illegal to pass an option after the filenames.. Remote debug a linux app from XCode Ananother possibility is this for any reason #{HOST} will be empty when running under cron. Test for external undefined references in LinuxThen the whole call expands to mkdir -p, which again, depending on your implementation of mkdir might be interpreted as "create one directory named -p".. Problem when compressing SWF in Linux with java.util.zip It is not quite clear to me why you are passing the options and operands in the wrong order, instead of mkdir -p #{HOST}. It's also not clear to me why you use the shell at all, instead of just FileUtils.mkdir_p(HOST)..

2:

Ananother problem I've seen is the #! script line fails when /usr/bin/env is used. For instance:. #!/usr/bin/env ruby. doesn't find ruby when running under cron. You have to use. #!/usr/local/bin/ruby. or the equivalent on your platform..


70 out of 100 based on 55 user ratings 330 reviews