PDA

View Full Version : appending timestamp to a custom log




vrinek502
Mar 2, 2006, 11:44 AM
What I'm trying here is to append the timestamp to a text file every minute. This would be useful to tracking time and date of sleeping (for battery life measurement) and for not letting the disk to sleep (major problem with externals while editing video, getting a cup of coffee and waiting 30secs for spin up).
I know it can be done with a simple shell script, but I don't know how (not much previous Unix experience).

This is roughly what I try to do:
get current date (in format yyyyMMdd.hhmmss)
append it (add it to the end) to the file stamp.log in the working directory
exit

Can somebody help me?



zimv20
Mar 2, 2006, 11:47 AM
#!/bin/sh

LOGFILE=<however you get the name of your logfile>

date "+%Y%m%d.%H%M%S" >> $LOGFILE

vrinek502
Mar 2, 2006, 12:56 PM
Thank you zimv20

then I just add it to my crontab, right?

zimv20
Mar 2, 2006, 01:10 PM
yeah, crontab should work.