Crontab and ruby script

Hi all,

I used crontab command such as
"*/5 * * * * /usr/local/bin/ruby /local/myuser/rubyscript/script1.rb"

But it can't execute script1.rb, I let it print some message every 5
min.

I also changed script1.rb to chmod 755.

Does the crontab command is right?

Thanks.

···

--
Posted via http://www.ruby-forum.com/.

Looks ok. I don't think you need execute permission either, just read permission would do, because you're passing the file to the interpreter.

Verify that:
     * Interpreter path is correct
     * Program does not have errors and you are able to run it yourself
     * It has correct permissions for accessing files etc as the user you've setup the cron for
     * If you're just printing stuff remember it doesn't have $stdout or $stderr to write to, redirect those to some log file

Hope this helps

···

On 05/01/12 4:00 PM, CC Chen wrote:

Hi all,

I used crontab command such as
"*/5 * * * * /usr/local/bin/ruby /local/myuser/rubyscript/script1.rb"

But it can't execute script1.rb, I let it print some message every 5
min.

I also changed script1.rb to chmod 755.

Does the crontab command is right?

Thanks.

I am quite noob
however...
if your script does use gui, maybe you must use
DISPLAY=:0.0
*/5 * * * * /usr/local/bin/ruby /local/myuser/rubyscript/script1.rb

a useful link may be

CC Chen wrote in post #1039530:

···

Hi all,

I used crontab command such as
"*/5 * * * * /usr/local/bin/ruby /local/myuser/rubyscript/script1.rb"

But it can't execute script1.rb, I let it print some message every 5
min.

I also changed script1.rb to chmod 755.

Does the crontab command is right?

Thanks.

--
Posted via http://www.ruby-forum.com/\.

Run 'env -i $SHELL --norc'. It will bring up a new naked shell that is equivalent to what cron runs. Run your command as-is in this shell to ensure it works correctly.

···

On Jan 5, 2012, at 02:30 , CC Chen wrote:

Hi all,

I used crontab command such as
"*/5 * * * * /usr/local/bin/ruby /local/myuser/rubyscript/script1.rb"

But it can't execute script1.rb, I let it print some message every 5
min.

I also changed script1.rb to chmod 755.

Does the crontab command is right?

CC Chen wrote in post #1039530:

Hi all,

I used crontab command such as
"*/5 * * * * /usr/local/bin/ruby /local/myuser/rubyscript/script1.rb"

But it can't execute script1.rb, I let it print some message every 5
min.

I also changed script1.rb to chmod 755.

Does the crontab command is right?

Thanks.

I write a script which it can link to ftp server and to download files.

I also used this command
"*/5 * * * * /usr/local/bin/ruby /local/myuser/rubyscript/ftpscript.rb

/local/myuser/rubyscript/ftplog.txt"

It just can dump ftplog.txt file but it can't download any file from the
ftp server.

What should I do??

Thanks,

···

--
Posted via http://www.ruby-forum.com/\.

You could also try using [whenever](http://github.com/javan/whenever\)

···

On Thu, Jan 5, 2012 at 10:34 AM, Giampiero Zanchi <cidza@tin.it> wrote:

I am quite noob
however...
if your script does use gui, maybe you must use
DISPLAY=:0.0
*/5 * * * * /usr/local/bin/ruby /local/myuser/rubyscript/script1.rb

a useful link may be
cron and crontab

CC Chen wrote in post #1039530:

Hi all,

I used crontab command such as
"*/5 * * * * /usr/local/bin/ruby /local/myuser/rubyscript/script1.rb"

But it can't execute script1.rb, I let it print some message every 5
min.

I also changed script1.rb to chmod 755.

Does the crontab command is right?

Thanks.

--
Posted via http://www.ruby-forum.com/\.

Venkatakrishnan Ganesh wrote in post #1039547:

Looks ok. I don't think you need execute permission either, just read
permission would do, because you're passing the file to the interpreter.

Verify that:
     * Interpreter path is correct
     * Program does not have errors and you are able to run it yourself
     * It has correct permissions for accessing files etc as the user
you've setup the cron for
     * If you're just printing stuff remember it doesn't have $stdout or
$stderr to write to, redirect those to some log file

Hope this helps

Thanks,

I changed to

" */5 * * * * /usr/local/bin/ruby /local/myuser/rubyscript/script1.rb >>
/local/myuser/rubyscript/log.txt "

It find the message dump on log.txt, but does it can't print out
directly??

···

--
Posted via http://www.ruby-forum.com/\.

Ryan Davis wrote in post #1039638:

···

On Jan 5, 2012, at 02:30 , CC Chen wrote:

Does the crontab command is right?

Run 'env -i $SHELL --norc'. It will bring up a new naked shell that is
equivalent to what cron runs. Run your command as-is in this shell to
ensure it works correctly.

So I add this command 'env -i $SHELL --norc' on crontab directly?

Thanks,

--
Posted via http://www.ruby-forum.com/\.

No. This was intended for testing only.

Btw, you do not have those quotes at the beginning and end of the line
in your crontab, do you? If yes, you must remove them.

Kind regards

robert

···

On Fri, Jan 6, 2012 at 3:20 AM, CC Chen <dickyhide@gmail.com> wrote:

Ryan Davis wrote in post #1039638:

On Jan 5, 2012, at 02:30 , CC Chen wrote:

Does the crontab command is right?

Run 'env -i $SHELL --norc'. It will bring up a new naked shell that is
equivalent to what cron runs. Run your command as-is in this shell to
ensure it works correctly.

So I add this command 'env -i $SHELL --norc' on crontab directly?

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/