Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > shutdown of linux box from cron perl script

Reply
Thread Tools

shutdown of linux box from cron perl script

 
 
Eric Peterson
Guest
Posts: n/a
 
      01-06-2005
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


 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      01-07-2005
"Eric Peterson" <> wrote in
newsgkDd.10900$ om:

> 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.

--
A. Sinan Unur
d
(remove '.invalid' and reverse each component for email address)

 
Reply With Quote
 
 
 
 
Keith Keller
Guest
Posts: n/a
 
      01-07-2005
["Followup-To:" header set to comp.os.linux.misc.]

On 2005-01-06, Eric Peterson <> wrote:
> 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

--
kkeller-
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

 
Reply With Quote
 
Eric Peterson
Guest
Posts: n/a
 
      01-07-2005

"A. Sinan Unur" <> wrote in message
news:Xns95D6C4031245Fasu1cornelledu@132.236.56.8.. .
> "Eric Peterson" <> wrote in
> newsgkDd.10900$ om:
>
> > 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).


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

>
> > 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.
>
> --
> A. Sinan Unur
> d
> (remove '.invalid' and reverse each component for email address)
>



 
Reply With Quote
 
Eric Peterson
Guest
Posts: n/a
 
      01-07-2005
Perfect!
Thanks!

"Abigail" <> wrote in message
news:.. .
> Eric Peterson () wrote on MMMMCXLVI
> September MCMXCIII in

<URL:newsgkDd.10900$ igy.com>:
> '' 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?
>
>
> Your PATH is probably different when running from cron. Try using
> the full path: /sbin/shutdown -r
>
>
> Abigail
> --
> $=-=4*++$|;{print$"x--$==>"\@\x7Fy~*kde~box*Zoxf*Bkiaox \r"
> ^
> $/x24if!select$,,$,,$,,join+q=.==>$^W=>$|;$=&&redo}s leep$|;



 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      01-07-2005
Eric Peterson wrote:
> 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
 
Reply With Quote
 
Steven_Smith
Guest
Posts: n/a
 
      01-10-2005
Joe Smith wrote:
> Eric Peterson wrote:
>
>> 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

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Perl to connect a Linux box to Linux/Windows boxes Krishna Chaitanya Perl Misc 1 02-27-2009 11:44 AM
problem starting perl script from cron environment - ps: don't knowwhich terminal to select Micha Perl Misc 2 03-23-2008 01:01 PM
Linux cron : problem with a ruby task Zouplaz Ruby 3 09-14-2006 03:07 PM
running perl script in cron Edward Perl Misc 1 05-13-2004 05:11 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57