0

So I asked a question on here a few weeks ago and the response I got was helpful but I figured I would add some info to get a better response.

I work with a computer system that has 8 servers (4 primary 4 alternates) and has 16 nodes on those servers (4 on each server with the same on each alternate). The nodes can't load until the servers come online. So I have been writing 2 lines of codes that are separate until I can figure out how to connect them together.

for i in `echo server1; echo server2; echo server 3; echo server4; echo server5; echo server6; echo server7; echo server8`; do
echo $i
/remcmd $i username password 'superuser /reboot'
echo
done

Then my second command would be

for i in `echo node1; echo node2; echo node3; echo node4; echo node5; echo node6; echo node7; echo node8; echo node9; echo node10; echo node11; echo node12; echo node13; echo node14; echo node15; echo node16
/remcmd $i username password 'superuser /reboot'

Is there a way to reboot the servers then wait for 9 minutes then to reboot the nodes. I have tried piping but did some research and it doesn't like it.

Any help anyone could give, I would appreciate it.

  • 4
    Your echos are superfluous. If your naming conventions are sane (i.e. no whitespace), you can say for i in node1 node2 node3; do something; done – Ulrich Schwarz May 17 '14 at 7:20
  • What is a "node" in your parlance? A virtual machine and the servers are the hosts? A software service? It sounds like you expect your nodes to survive the underlying server being rebooted, or else you'd not reboot them manually. – Ulrich Schwarz May 17 '14 at 7:23
  • The nodes are computers for people to use. They boot off the information from the servers. – Westberlinbombr May 17 '14 at 9:33
1

Use at to schedule a command in the future (man at for usage). Either on your server or on the nodes depending on what they are and which would be better suited to control the reboot.

servers="server1 server2 server3 server4"
nodes="node1 node2 node3 node4"
remcmd="something"

for server in $servers; do
  echo "server [$server]"

  for node in $nodes; do
    echo "node [$node]"

    # Locally schedule a node reboot in 9 minutes
    at now + 9 minutes <<< "$remcmd $node username password 'superuser /reboot'"

    # or remotely schedule the node reboot
    $remcmd $node username password 'at now + 9 minutes <<< "superuser /reboot"'
  done    

  # Reboot server now
  $remcmd $server username password 'superuser /reboot'
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.