Ruby and cron help

Hi, rubyists.

I think this is more a cron rather than a ruby problem.
However, I am stumped.

I am running ruby 1.6.8 under Solaris 6.

wcary3zg:~/src/ruby/utils% crontab -l
0,15,30,45 * * * * /opt/home/mark/bin/blah

wcary3zg:~/src/ruby/utils% cat ~/bin/blah
#! /usr/local/bin/zsh
cd ~/src/ruby/utils
/usr/local/bin/ruby timestamp.rb > ~/tmp/timestamp.out
/usr/local/bin/ruby blah.rb > ~/tmp/blah.out

timestamp.rb contains “puts Time.now” just to show that
ruby is working ok. blah.rb is the application I am
really interested in. Running “blah” from the command
line works fine. It fails to work from cron, though
the command is executed (from /var/cron/log) and the
timestamp.out file is updated.

Any ideas?

···


-mark.


Mark Probert probertm@NOSPAM_nortelnetworks.com
Nortel Networks ph. (613) 768-1082

All opinions expressed are my own and do not
reflect in any way those of Nortel Networks.

Mark Probert wrote:

Hi, rubyists.

I think this is more a cron rather than a ruby problem.
However, I am stumped.

I am running ruby 1.6.8 under Solaris 6.

wcary3zg:~/src/ruby/utils% crontab -l
0,15,30,45 * * * * /opt/home/mark/bin/blah

wcary3zg:~/src/ruby/utils% cat ~/bin/blah
#! /usr/local/bin/zsh
cd ~/src/ruby/utils
/usr/local/bin/ruby timestamp.rb > ~/tmp/timestamp.out
/usr/local/bin/ruby blah.rb > ~/tmp/blah.out

timestamp.rb contains “puts Time.now” just to show that
ruby is working ok. blah.rb is the application I am
really interested in. Running “blah” from the command
line works fine. It fails to work from cron, though
the command is executed (from /var/cron/log) and the
timestamp.out file is updated.

Any ideas?

Does blah run if you comment out the timestamp line?

what happens if you replace

timestamp.rb

and

blah.rb

with their absolute paths?

you could try changing

/usr/local/bin/ruby blah.rb > ~/tmp/blah.out

to

/usr/local/bin/ruby blah.rb

and see what cron mails you.

-a

···

On Fri, 21 Mar 2003, Mark Probert wrote:

Hi, rubyists.

I think this is more a cron rather than a ruby problem.
However, I am stumped.

I am running ruby 1.6.8 under Solaris 6.

wcary3zg:~/src/ruby/utils% crontab -l
0,15,30,45 * * * * /opt/home/mark/bin/blah

wcary3zg:~/src/ruby/utils% cat ~/bin/blah
#! /usr/local/bin/zsh
cd ~/src/ruby/utils
/usr/local/bin/ruby timestamp.rb > ~/tmp/timestamp.out
/usr/local/bin/ruby blah.rb > ~/tmp/blah.out

timestamp.rb contains “puts Time.now” just to show that
ruby is working ok. blah.rb is the application I am
really interested in. Running “blah” from the command
line works fine. It fails to work from cron, though
the command is executed (from /var/cron/log) and the
timestamp.out file is updated.

Any ideas?


-mark.


Mark Probert probertm@NOSPAM_nortelnetworks.com
Nortel Networks ph. (613) 768-1082

All opinions expressed are my own and do not
reflect in any way those of Nortel Networks.

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================

Mark Probert wrote:

Hi, rubyists.

I think this is more a cron rather than a ruby problem.
However, I am stumped.

I am running ruby 1.6.8 under Solaris 6.

wcary3zg:~/src/ruby/utils% crontab -l
0,15,30,45 * * * * /opt/home/mark/bin/blah

wcary3zg:~/src/ruby/utils% cat ~/bin/blah
#! /usr/local/bin/zsh
cd ~/src/ruby/utils
/usr/local/bin/ruby timestamp.rb > ~/tmp/timestamp.out
/usr/local/bin/ruby blah.rb > ~/tmp/blah.out

timestamp.rb contains “puts Time.now” just to show that
ruby is working ok. blah.rb is the application I am
really interested in. Running “blah” from the command
line works fine. It fails to work from cron, though
the command is executed (from /var/cron/log) and the
timestamp.out file is updated.

Any ideas?

Just to make sure all the output from the command are captured,
you may want to do this.

cd ~/src/ruby/utils
/usr/local/bin/ruby timestamp.rb > ~/tmp/timestamp.out 2>&1
/usr/local/bin/ruby blah.rb > ~/tmp/blah.out 2>&1

and check the output

Also, if your login shell is not of the csh variety, try testing
it with

rsh localhost /opt/home/mark/bin/blah

This emulates pretty well the cron execution environment. cron
run a program with almost none of your environment, so you need to
setup most environment variables that is normally in .profile/.cshrc

Joel VanderWerf wrote:

Mark Probert wrote:
Hi, rubyists.

I think this is more a cron rather than a ruby problem.
However, I am stumped.

I am running ruby 1.6.8 under Solaris 6.

wcary3zg:~/src/ruby/utils% crontab -l
0,15,30,45 * * * * /opt/home/mark/bin/blah

0,15,30,45 * * * * /opt/home/mark/bin/blah 2>~/tmp/blah.err

See what shows up in blah.err.

Also, with DBI/Oracle I’ve noticed that I explictly have to set some
environment variables for cron by including “/usr/bin/env VAR=val”, etc.

Regards,

Dan

Joel VanderWerf vjoel@PATH.Berkeley.EDU did say …

Does blah run if you comment out the timestamp line?

No, unfortunately. The idea of the timestamp line was
to see if it was a problem running ruby, or cron, or
the driver. They all seem to be ok.

The output of /var/cron/log is

CMD: /opt/home/mark/bin/blah
mark 761 c Fri Mar 21 15:00:00 2003
< mark 761 c Fri Mar 21 15:00:00 2003 rc=1

The script will runtime is around 10 mins (there
are 2 x 5 minute intentional sleeps).

Is there anyway of working out what cron is doing or
capturing the output? I have tried

0,15,30,45 * * * * /opt/home/mark/bin/vtx1 > ~/tmp/cron.out 2>&1

though the cron.out file is empty …

Thanks for your help,

···


-mark.


Mark Probert probertm@NOSPAM_nortelnetworks.com
Nortel Networks ph. (613) 768-1082

All opinions expressed are my own and do not
reflect in any way those of Nortel Networks.

ahoward ahoward@fsl.noaa.gov did say …

what happens if you replace

timestamp.rb

and

blah.rb

with their absolute paths?

Same effect

you could try changing

/usr/local/bin/ruby blah.rb > ~/tmp/blah.out

to

/usr/local/bin/ruby blah.rb

and see what cron mails you.

-smile-

Nothing …

Thanks for your help!

···

On Fri, 21 Mar 2003, Mark Probert wrote:


-mark.


Mark Probert probertm@NOSPAM_nortelnetworks.com
Nortel Networks ph. (613) 768-1082

All opinions expressed are my own and do not
reflect in any way those of Nortel Networks.

Mark Probert wrote:

0,15,30,45 * * * * /opt/home/mark/bin/vtx1 > ~/tmp/cron.out 2>&1

I’ve had trouble using ~ in crontab, so I use $HOME, which seems to
work. (Solaris 7, anyway.)

Yeah, Solaris’ /bin/sh doesn’t even grok ~.

Have you tried truss’ing cron and its children right before the job is
supposed to run? Something like:

$ truss -o /tmp/cron.trace -vall -f -p <cron pid>

Then check /tmp/cron.trace after the job has ran. I know, it’s a sledgehammer
approach…

···

On Sat, Mar 22, 2003 at 05:55:03AM +0900, Joel VanderWerf wrote:

Mark Probert wrote:

0,15,30,45 * * * * /opt/home/mark/bin/vtx1 > ~/tmp/cron.out 2>&1

I’ve had trouble using ~ in crontab, so I use $HOME, which seems to
work. (Solaris 7, anyway.)


Jos Backus / /// Sunnyvale, CA
_/ _/ _/
/ ///
_/ _/ _/ /
jos at catnook.com // //
/ require ‘std/disclaimer’