LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 04-06-2011, 07:32 AM   #1
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 557

Rep: Reputation: 46
Lightbulb Date and NTP


Let's suppose there are "n" number of servers in a Linux cluster / network environment. We want to make sure that "date" on all those servers are in sync. How can we log the output of "date" to a particular file (log file, let's name it /tmp/date.log on our local system from where we are executing our command or script) run on every server one by one so that we can have a log of all the servers and their corresponding date vales in the following format:

---------------------------------------
Server Date
---------------------------------------
Node1 Wed Apr 6 13:30:06 BST 2011
Node2 Wed Apr 6 13:30:06 BST 2011
NodeX Wed Apr 6 13:30:06 BST 2011
---------------------------------------

The purpose is we want to make sure that date is in sync on all the nodes/servers.

Any ideas?


Please note: We do not want to shh / telnet to each and every server manually and then execute the date command. We want to achieve it all in one go!

Last edited by devUnix; 04-06-2011 at 07:33 AM.
 
Old 04-06-2011, 09:06 AM   #2
tsg
Member
 
Registered: Mar 2008
Posts: 155

Rep: Reputation: 30
ssh accepts a command, so it could be as simple as a script running
Code:
ssh Node1 date
ssh Node2 date
ssh NodeX date
with standard output redirected to a log file.
 
Old 04-06-2011, 09:31 AM   #3
xmmm
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Rep: Reputation: 1
My approach will be:

1. setup NTP client on every server to sync to a NTP server
2. Use a script or something like Nagios to make sure the clock does not go off.
 
Old 04-06-2011, 09:48 AM   #4
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 557

Original Poster
Rep: Reputation: 46
Quote:
Originally Posted by tsg View Post
ssh accepts a command, so it could be as simple as a script running
Code:
ssh Node1 date
ssh Node2 date
ssh NodeX date
with standard output redirected to a log file.
Yes, it doesn. But you are prompted for password.
 
Old 04-06-2011, 09:57 AM   #5
tsg
Member
 
Registered: Mar 2008
Posts: 155

Rep: Reputation: 30
Quote:
Originally Posted by devUnix View Post
Yes, it doesn. But you are prompted for password.
You can set up an ssh-key that doesn't require a password, or you can use ssh-agent to remember a password for the session.
 
Old 04-06-2011, 01:50 PM   #6
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 557

Original Poster
Rep: Reputation: 46
Well, I have found a solution. So, I am closing this thread. The solution is: use a public key (ssh key) on a remote server and thereby eliminating the need for entering password.
 
  


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
ntp drift file in /etc/ntp instead of /var/lib/ntp - suggestion for a patch in Slack niels.horn Slackware 16 05-07-2009 07:35 PM
date / ntp problem sp149 Red Hat 3 02-07-2008 11:23 AM
ntp does not work.. date and time cannot be changed.. basis1980 Linux - Software 10 02-06-2008 08:09 AM
ntp port blocked - how to set date automatically unkie888 Linux - General 4 11-06-2007 05:57 AM
NTP cannot work with timeserver, NTP-d can jerryvapps Linux - Networking 0 08-04-2004 02:04 PM


All times are GMT -5. The time now is 12:20 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration