LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 08-14-2008, 10:54 PM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 31
send system time to a file


I would like to send the system tme to a log ( /tmp/log ) in every 5 seconds , now I manually run "date >> /tmp/log" in every 5 seconds , it is OK , but how can I let it automatically do it ? thx


What I would like the log is
===================
#vi /tmp/log
Fri Aug 15 11:50:15 GMT 2008
Fri Aug 15 11:50:20 GMT 2008
Fri Aug 15 11:50:25 GMT 2008
Fri Aug 15 11:50:30 GMT 2008
Fri Aug 15 11:50:35 GMT 2008
Fri Aug 15 11:50:40 GMT 2008
 
Old 08-14-2008, 11:25 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Code:
while : ;  do
   date >> /tmp/log
   sleep 5
done
 
Old 08-14-2008, 11:44 PM   #3
kwesadilo
LQ Newbie
 
Registered: Mar 2007
Posts: 12

Rep: Reputation: 0
You could make a shell script (which I will call sendtime) like this:
Code:
#!/bin/bash

while true
do
    date >> /tmp/log
    sleep 5
done
Make it executable with chmod u+x sendtime. Then you start it in the background with ./sendtime &.

There are ways to make it automatically start up when you start the computer or when you log in. If that was what you wanted, you'll have to wait for somebody more knowledgeable.
 
Old 08-15-2008, 09:10 AM   #4
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
If you are trying to debug clock problems on that box you'll need to have another machine do it. Essentially 2 scripts one on the other machine and one on the machine your doing the clock check on. Setup a ssh key so you can do passwordless connects, then run a script like those above except instead of the date command it does an ssh command that runs a script that does the date >> /tmp/log on the machine your doing the clock check on.
 
  


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
How to find the time a paritcular file system was mounted neuralninja Linux - Newbie 1 04-04-2008 02:21 PM
Is there a way to send files to a friend, similar to MSN send file protocol? pablom Linux - Networking 1 05-07-2007 10:16 PM
boot time NTFS errors on ext2 file system adrianmariano Linux - Hardware 2 01-14-2005 06:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:34 AM.

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