verify date and time on unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting verify date and time on unix
# 1  
Old 07-25-2005
Error verify date and time on unix

Hello all,
I'm sorry for such a silly help.
I have 8 unix machines which include AIX, IRIX, HPUX, SGI.
I wanted a script that would compare/ check the date and time on all machine and send me a mail if some system has different date. how can i do it with a single script
It can check date and hour and if possb min.

I would be thanksful if any one could help me with this.

Regards,
Pradeep Kulkarni.
# 2  
Old 07-25-2005
Hi Pradeep,

To get the current time of any machine, try to read the data from port no 13.

For e.g. Using telnet :

Telnet <machine name> 13

Trying <I.P Address>...
Connected to <remote host>.
Escape character is '^]'.
Mon Jul 25 18:37:04 2005
Connection closed by foreign host.

U can get the current time for remote machine.

Regards,
Amit Sapre
# 3  
Old 07-25-2005
Why not use NTP (Network Time Protocol) to maintain time on all servers? Here is a link to info about NTP on HP servers, and here is a link to NTP on Sun.
# 4  
Old 07-25-2005
it is better to you run NTP on your UNIX hosts... and synchronize them with another NTP server on the internet, say time.nist.gov
# 5  
Old 07-30-2005
Hello all,
Sorry for the delay in reply. i knew about NTP but i wantd a script that would post a mail to me about this information.
i did try Telnet <machine name> 13 and it works but how do i capture this data and put it in file and mail...???

Rgds,
Pradeep Kulkarni.
# 6  
Old 08-01-2005
You could try this code :

toto=`telnet <machine name> 13`
datetime=`echo ${toto} | cut -d' ' -f10-`

Regards.
# 7  
Old 08-02-2005
Quote:
Originally Posted by madmat
You could try this code :

toto=`telnet <machine name> 13`
datetime=`echo ${toto} | cut -d' ' -f10-`

Regards.

Thanks a lot for the help it works, a small change

toto=`telnet <machine name> 13`
datetime=`echo ${toto} | cut -d' ' -f9-12`
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change the date and time format in UNIX script.

Hi, I am extracting a date string from the source file like this : 06/05/2014 16:04:00 I want to change it to 05-JUN-14 04.05.00.000000000 PM I basically store the date in a variable. I got solutions to change date in dd-mmm-yyyy format using tr but I guess it works only with the "date"... (8 Replies)
Discussion started by: Varshha
8 Replies

2. Shell Programming and Scripting

Date time difference in UNIX shell script

There are 2 dates, Tue Oct 1 13:40:19 2013 Sun Sept 30 10:26:23 2013 I have multiple dates like the above one. How do I calculate the date time difference and display in another column in Shell script. Please help. (3 Replies)
Discussion started by: tanmoysays
3 Replies

3. Shell Programming and Scripting

Adding time to date time in UNIX shell scipting

I needed some help in adding a duration (in seconds) to a start time (in hhmmss format) and a start date (in mmddyy format) in order to get an end date and end time. The concept of a leap year is also to be considered while incrementing the day. The code/ function that I have formed so far is as... (3 Replies)
Discussion started by: codehelp04
3 Replies

4. Solaris

modifying date and time and time zone on solaris 5.10 with (redundant server) veritas

I have a cluster of two Solaris server (veritas cluster). one working and the other is standby I am going to change the date on them , and am looking for a secure solution as it is giving an important service. my opinion is that the active one doesn't need to be restarted (if I don't change the... (1 Reply)
Discussion started by: barry1946
1 Replies

5. UNIX for Dummies Questions & Answers

Converting string date time to unix time in AWK

I'd like to convert a date string in the form of sun aug 19 09:03:10 EDT 2012, to unixtime timestamp using awk. I tried This is how each line of the file looks like, different date and time in this format Sun Aug 19 08:33:45 EDT 2012, user1(108.6.217.236) all: test on the 17th ... (2 Replies)
Discussion started by: bkkid
2 Replies

6. UNIX for Dummies Questions & Answers

Formatting date time in unix using perl breaks

while read l do vTimeCreated=`perl -e '@d=localtime ((stat(shift))); printf "%02d-%02d-%04d %02d:% 02d:%02d\n", $d,$d+1,$d+1900,$d,$d,$d' ${l}` echo "${l} || ${vTimeCreated}" >> ${fPrefx}_Output_Files_${vDate}.txt done < servername.txt Using the above code to format date time for each of... (5 Replies)
Discussion started by: HeadBang
5 Replies

7. Shell Programming and Scripting

Formatting date time in unix

while read l do vTimeCreated=`perl -e '@d=localtime ((stat(shift))); printf "%02d-%02d-%04d %02d:% 02d:%02d\n", $d,$d+1,$d+1900,$d,$d,$d' ${l}` echo "${l} || ${vTimeCreated}" >> ${fPrefx}_Output_Files_${vDate}.txt done < servername.txt Using the above code to format date time for each of the... (0 Replies)
Discussion started by: HeadBang
0 Replies

8. Shell Programming and Scripting

Convert date to unix time

Hi, I need to convert a date in the format yyyy-mm-dd to unix seconds, shell script or perl would be ok since there is no hour/second, we can assume 12am every day thanks in advance funksen (4 Replies)
Discussion started by: funksen
4 Replies

9. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

10. Shell Programming and Scripting

Listing the creation date/time of a file in unix

Hi, I need the unix command which returns only the file name and its creation date/time in unix. I tried ls -l <filename>. But that is giving other details also which I do not want. Could anyone help me out? Thanks. (6 Replies)
Discussion started by: unipepper
6 Replies
Login or Register to Ask a Question