yogio
asked on
Linux For Loop
How can I write a script to shutdown some remote Linux servers. I believe I need to create a list of IP addresses for the servers to have the script loop to it, then ssh into as root and shut it down with the shutdown command. Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There shouldn't be a hang - the ssh call will run the command and exit as soon as it finishes.
It can be a problem if you log onto the remote server and issue the "shutdown now" command manually. In that case, you could issue the command
exec shutdown now
so that the session ends as soon as the command completes (and before the machine shuts down).
It can be a problem if you log onto the remote server and issue the "shutdown now" command manually. In that case, you could issue the command
exec shutdown now
so that the session ends as soon as the command completes (and before the machine shuts down).
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all the help.
Usually root login might not be allowed, the use of a Setuid script or sudo shutdown now ;exit might be a way to go.