简体   繁体   中英

Services start and stop script [on hold]

Can someone help me with the Bash script for starting and stopping services.

The requirement is if there are 4 servers: Server 1, Server 2, Server 3, Server 4, we need to start and stop the services in a sequential order.

Suppose if we do some patch updates and shutdown the servers the all the services on Server 4 should go down and then 3 then 2 then 1. On reboot, it should be vice versa ie Services on Server 1, then 2 then 3 and finally 4.

Please suggest how this can be automated.

I am very new to Scripting, Can someone help me with this.

EDIT: This community is horrible, getting "-2" for telling this person what would be needed? They clearly state they are new, and it clearly marked my profile as "NEW CONTRIBUTOR". I attempt to help this person know what they have to give additionally, plus a basic outline.

There has been talk about how unwelcoming this community is and even a blog post about it. https://stackoverflow.blog/2018/04/26/stack-overflow-isnt-very-welcoming-its-time-for-that-to-change/ and after reading it I thought "well cool they have brought it up and are working on it." guess not.

You are ridiculous, I will be deleting my account following this edit.

yep

Original:

So some additional information will be needed here. It is not really possible to do much with what is present other than general idea flow, which I encluded at the end.

Needed:

  • What flavor of Linux are you using? Matters as there is more than one option to start/stop services proper.
  • What application/applications? Is this a public one, custom one, special stop procedures?
  • You can't stop all services, as ssh/sshd is one of them.
  • Why is reboot needed or were you just using that as a services up wording?

Basic flow:

Down:

Initialize an array of variables for all the services per machine.
ssh machine 4, run down commands, verify down, send back ok for variables.
logic verify machine 4 down success.
ssh machine 3, repeat down procedure 
.... (Repeat as needed)
logic verify all machines down.
announce clear.

Upgrade your software.

Up:

Initialize an array of variables for all the services per machine.
ssh machine 1, run up commands, verify up, send back ok for variables.
logic to verify machine 1 up.
... (Repeat as needed)
logic verify all up
announce all clear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM