shutdown of linux box from cron perl script - Linux

This is a discussion on shutdown of linux box from cron perl script - Linux ; 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 ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: shutdown of linux box from cron perl script

  1. shutdown of linux box from cron perl script

    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



  2. Re: shutdown of linux box from cron perl script

    ["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-usenet@wombat.san-francisco.ca.us
    (try just my userid to email me)
    AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom


  3. Re: shutdown of linux box from cron perl script

    Eric Peterson (lastname_nospam@heritage.nv.gov) wrote on MMMMCXLVI
    September MCMXCIII in gkDd.10900$by5.8889@newssvr19.news.prodigy.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}sleep$|;

  4. Re: shutdown of linux box from cron perl script

    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

  5. Re: shutdown of linux box from cron perl script

    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 to Thread