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

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



Hi,

On Wed, Aug 12, 2009 at 09:52:45AM -0700, David Christensen wrote:
> Alex Samad wrote:
> > try sudo shutdown -h +1 \&
> > the & is being gobbled by the shell you are in not the sudo shell

????

> Nope -- that also blocked.

I think root cause is SIGTERM  (just guessing) ...

> carries out the request.  STFW and RTFM, the 'at' command can do that
> 
>     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. :-)

Certainly ... I recommend "at" command.  It capture STDOUT/STDERROR and
send it to mail.  But why wait :-) 

By the way, test following to understand real reason why you had trouble ...

Your console is used by shutdown and upon killing ssh connection,
shutdown program get signal since its connected terminal dies.

Test1:

redirect STDOUT/STDERR

$ sudo shutdown -h +1 >/dev/null 2>/dev/null &

Test 2:

run shutdown in screen program.
 http://www.debian.org/doc/manuals/debian-reference/ch09.en.html#_the_screen_program

Osamu


Reply to: