Link to home
Start Free TrialLog in
Avatar of marceloNYC
marceloNYCFlag for United States of America

asked on

Linux shell script to reboot a few linux machines

Dear experts,

I am task with something I have never done before.

I am sure is easy for some of you :)

I need to execute a linux shell script from our network that will connect ssh to this devices and reboot them with 15 minutes difference.

I imagine it will look something like this:

 #!/bin/bash

USERNAME=someUser
HOSTS="host1 host2 host3"
SCRIPT="pwd; ls"
for HOSTNAME in ${HOSTS} ; do
    ssh -l ${USERNAME} ${HOSTNAME} "${SCRIPT}"
done
Need to connect the reboot command with the ssh connection

for p in server1 server2 server3
do
  ssh ${p} sudo reboot
  sleep 900

 I need it to connect and reboot after 15 minutes from the first machine rebooted.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Steven Vona
Steven Vona
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marceloNYC

ASKER

Thank you!