Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 ( #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
Node Status?
node history
Node Type: note [id://781940]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-12-27 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls