Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: ssh connection lost during script running when box rebooted and script falls out...

by quester (Vicar)
on Jul 21, 2009 at 12:34 UTC ( [id://781940]=note: print w/replies, xml ) Need Help??


in reply to ssh connection lost during script running when box rebooted and script falls out...

The easiest way to handle this would be to log off before the box shuts down, so it doesn't hang the ssh session. You could try replacing the shutdown command with this (untested):
(sleep 3; shutdown) & exit
You will want to change the sleep 2; call in your script to be considerably longer to give the remote system a chance to shut down, reboot and start up its ssh daemon. Or, better, enclose the last call to Net::SSH::Expect->new in a loop and retry it a reasonable number of times, sleeping a while between tries. This will let you connect reasonably quickly without dying if the remote system unexpected takes longer than usual to reboot (for example, if you are running SELinux and the /.autorelabel file exists.)
  • Comment on Re: ssh connection lost during script running when box rebooted and script falls out...
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://781940]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-26 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found