[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE: how to start a delayed shutdown over ssh and disconnect immediately?



Alex Samad wrote:
> try sudo shutdown -h +1 \&
> the & is being gobbled by the shell you are in not the sudo shell

Thank you for your response.  :-)

    2009-08-12 08:38:37 dpchrist@p43400e /cygdrive/u
    $ ssh p3450 sudo shutdown -h +1 \&
    2009-08-12 08:39:47 dpchrist@p43400e /cygdrive/u
    $

Nope -- that also blocked.


> i usually use sudo poweroff \& ; exit

    2009-08-12 08:58:00 dpchrist@p3450 ~
    $ man poweroff

I don't see a time delay option for poweroff.  I need a time delay to
solve chicken and egg problems with shared folders, name resolution,
etc. -- e.g. I need to tell all the machines to shutdown while they're
all still running.  If the wrong machine shutdowns down prematurely, the
overall shutdown script fails and I end up with some machines up and
some machines down.


Also, shutdown looks like a low-level routine that expects me to deal
with stopping services, flushing drives, etc..  I'd rather not risk it.


Thinking about the ssh/ shutdown approach some more, perhaps what I'm
wishing for can't be done this way because my SSH process is the parent
of sudo, which is the parent of shutdown, and parents can't exit until
all their children have exited (?).


Perhaps what I need is a client/ server approach -- e.g. the client
makes a request for a delayed shutdown and disconnects, and the server
carries out the request.  STFW and RTFM, the 'at' command can do that
for me:

    2009-08-12 09:12:08 dpchrist@p43400e /cygdrive/u
    $ ssh p3450 'echo "sudo shutdown -h now" > foo; chmod +x foo; at -f
foo now +1 minutes'
    warning: commands will be executed using /bin/sh
    job 1 at Wed Aug 12 09:16:00 2009


Much better. :-)


David



Reply to: