Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to log time

Status
Not open for further replies.

JB009

Programmer
Mar 29, 2006
7
US
Hi I need to script that will log the current time from the system to a text file, at a given interval (ex. every 5 mts). I'm new to Unix scripting, so any help would be greatly apperciate.

Thanks!
 
man cron
man date

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This solution has already been covered, believe it or not. However, given that you are an admitted newbie and you were given 480 lines of [tt]man[/tt] pages to search for udunnowhat, I thought it would b better to provide you with a little more guidance ...

You need a cron job to run every five minutes. Use [tt]crontab -e[/tt] to edit your cron jobs. The line should look like this:
Code:
0,5,10,15,20,25,30,35,40,45,50,55 * * * *  date +"%H:%M:%S" >> /tmp/somegroovyfile.txt

Note :
[tt]The -e option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. After you exit from the editor, the modified crontab will be installed automatically.[/tt]

If neither of those variables are set, the default depends on your flavor of Unix.

--
-- Ghodmode
 
...and perhaps don't post your homework? I don't think crontab -e is the way to go for a novice either.
 
Thanks all for the help, especially 'Ghodmode' for sample code.
 
be careful with '%' in crontab.

man crontab said:
The sixth field of a line in a crontab file is a string that
is executed by the shell at teh specified times. A percent character in this field (unless excaped by \) is translated to a NEWLINE character.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top