shutdown of linux box from cron perl script

E

Eric Peterson

Sorry for the cross-posting, but I'm not sure if this question lands on the
perl side of things, or the linux side...

I have a perl script that runs once a minute to check various things. Under
one condition I want it to reboot the system. The command line equivalent
of "shutdown -r 10". I can get the script to work perfectly if I manually
run it from the command-line, "./myshutdownscript.pl". But when it runs
automatically from cron, the shutdown command seems to be ignored, though
all other output indicates the perl script is running fine.

Any suggestions?

Using: Debian Sarge, kernel 2.6, pentiumIII box, Perl 5.8.4

Thanks!
-Eric
 
A

A. Sinan Unur

Sorry for the cross-posting, but I'm not sure if this question lands
on the perl side of things, or the linux side...

Well, I tried setting follow ups to comp.os.linux but it seems that group
is defunct (the most recent message on Google is from September 04).
I have a perl script that runs once a minute to check various things.
Under one condition I want it to reboot the system. The command line
equivalent of "shutdown -r 10". I can get the script to work
perfectly if I manually run it from the command-line,
"./myshutdownscript.pl". But when it runs automatically from cron,
the shutdown command seems to be ignored, though all other output
indicates the perl script is running fine.

A reasonable assumption is that cron jobs run with different priviliges.

That is an OS issue. Please post in an appropriate forum.
 
K

Keith Keller

["Followup-To:" header set to comp.os.linux.misc.]

Sorry for the cross-posting, but I'm not sure if this question lands on the
perl side of things, or the linux side...

I have a perl script that runs once a minute to check various things. Under
one condition I want it to reboot the system. The command line equivalent
of "shutdown -r 10". I can get the script to work perfectly if I manually
run it from the command-line, "./myshutdownscript.pl". But when it runs
automatically from cron, the shutdown command seems to be ignored, though
all other output indicates the perl script is running fine.

I'd try posting to comp.os.linux.misc instead, and also would post a
short script which replicates the problem there. (Sinan's correct, in
that if the script runs from the command line, it's probably not a Perl
problem.)

--keith
 
E

Eric Peterson

A. Sinan Unur said:
Well, I tried setting follow ups to comp.os.linux but it seems that group
is defunct (the most recent message on Google is from September 04).

Odd. I see messages there from earlier this week. I'm getting them from
the news server at sbcglobal.net
 
J

Joe Smith

Eric said:
runs automatically from cron, the shutdown command seems to be ignored

The perl answer to this problem is to add a line to your script:

$ENV{PATH} .= ':/sbin:/usr/sbin' unless $ENV{PATH} =~ /sbin/;

-Joe
 
S

Steven_Smith

Joe said:
The perl answer to this problem is to add a line to your script:

$ENV{PATH} .= ':/sbin:/usr/sbin' unless $ENV{PATH} =~ /sbin/;

-Joe
Or in general to use the absolute path to the executable if
there can be problems. Actually, for scripts used by many
people I've been bitten by not using the absolute path
several times, so generally I use it. The problem of course
is that then you can become platform specific...

Steve S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top