LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-26-2013, 09:35 AM   #1
santosh86
LQ Newbie
 
Registered: Jun 2013
Posts: 3

Rep: Reputation: Disabled
Need to stop/start a service in multiple machines


Hello guys,

This is my first post so please accept my apologies if it is in the wrong section.
Ok, this is what i want to achieve:

I have around 100 linux servers in my network. There are 3 services in each of them (samba, ntp and winbind) which i want to restart daily at a specific time. Now I am aware for a single machine I can run a cronjob script. But can you please suggest me a way to do the same in all 100 boxes without logging into each of them?
 
Old 06-26-2013, 09:39 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,445

Rep: Reputation: Disabled
You could create a list of all the servers and feed it to a script. The script could log in to each server, run the relevant command(s) to restart the services, and log back out.

Can you use the same credentials to log in to every server?
 
Old 06-26-2013, 10:48 AM   #3
santosh86
LQ Newbie
 
Registered: Jun 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Yes...most of them have the same username and password.
Can u also provide me with the script?
 
Old 06-26-2013, 12:32 PM   #4
Janus_Hyperion
Member
 
Registered: Mar 2011
Location: /
Distribution: Fedora (typically latest release or development release)
Posts: 372

Rep: Reputation: Disabled
Quote:
Originally Posted by santosh86 View Post
Yes...most of them have the same username and password.
Can u also provide me with the script?
Probably not. Most members of the forum will help you write a script. Not provide with one.
 
Old 06-26-2013, 01:21 PM   #5
santosh86
LQ Newbie
 
Registered: Jun 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Ok, i'll try to compile a script and post here. Please help me confirm if the script is proper.
 
Old 06-26-2013, 02:15 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,688

Rep: Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259
Quote:
Originally Posted by santosh86 View Post
Yes...most of them have the same username and password.
Can u also provide me with the script?
I would also suggest NOT using a password - instead, set up ssh certificates. Then you won't be hasseled by having to input a password for each system.
 
Old 06-26-2013, 07:12 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,357

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
As above, write a script that uses a loop of ssh accesses based on auth keys and feed it the list of server names (& accts if necessary).
Try these links
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

Incidentally, this technique is a pretty common requirement and you'll find plenty of other LQ threads that go through it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to start and stop squid service ? gardenair Linux - Networking 5 08-24-2014 05:13 AM
puppet needs to stop a service, do something, then start the service edwardcode Programming 1 12-03-2012 01:58 PM
[SOLVED] Start/stop SSH service? dilzniksan Debian 3 06-12-2010 08:47 PM
Can't start/stop Mysql Service dereko Linux - Server 1 06-28-2009 03:20 PM
start/stop service on the fly zchoyt Linux - Software 3 04-14-2005 03:30 AM


All times are GMT -5. The time now is 07:35 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration