Script to restart application services on remote systems
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Script to restart application services on remote systems
Hi,
I have a task of writing a script, in which it should check the runing of java process on multiple Linux remote systems ( around 170 servers) , If they are running then they should stop it and restart it.
Requirements:
1. stop the java process
2. Check for any orphan java process. IF yes, then kill it.
3. start the java process
4. recored the out out pf each four steps in a file.
5. Send the recoreded output in a mail.
It's not hard. You need an unified access method (ssh for example) and a file or different database with login/access info. Then, writing one simple script that does the task on a server is easy. It's harder to do the main part (loop trying all the servers) and it depends heavily on the access method.
Try to write first version of the script and see what you have problems with. Then, if you have more specific questions, just post them.
for i in `cat hostlist`; do ssh user@$i -C "remote-script" > server$i.log; done; tar czf --remove-files result.tar.gz server*.log; nail -a result.tar.gz -s "Results" user@email; rm result.tar.gz
Improve to your hearts content, e.g. I'm not doing any error checking, you may NOT
want to delete the result, but keep it versioned for a while ...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.