LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-02-2006, 09:30 AM   #1
vinayhr
LQ Newbie
 
Registered: Feb 2003
Posts: 2

Rep: Reputation: 0
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.

Could anybody please help me in doing this.

Thanks in advance.
 
Old 09-02-2006, 03:56 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
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.
 
Old 09-03-2006, 11:59 PM   #3
vinayhr
LQ Newbie
 
Registered: Feb 2003
Posts: 2

Original Poster
Rep: Reputation: 0
SSH part is working fine.

But I am confused as which method to use.

example: Should I use for loop or if statment.

If you have example script. could you please pass me on.
 
Old 09-04-2006, 12:37 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
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 ...


Cheers,
Tink
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Not stopping services at shutdown/restart, just S01reboot? make Linux - General 1 08-26-2004 05:20 PM
command to restart services djc Linux - Newbie 3 03-31-2004 02:04 PM
Keyboard and mouse services, how to restart shelby Linux - Hardware 0 03-13-2003 02:05 PM
Start Stop Restart Services Sifvion Slackware 6 09-14-2002 03:13 AM
How do I restart services in Linux rytskyo Linux - Newbie 3 05-06-2002 07:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration