[nycbug-talk] Scripting(Date&Time) Question
Kevin Reiter
tux at penguinnetwerx.net
Fri Dec 29 13:32:56 EST 2006
All,
Fairly simple (I think) question here:
When echoing the date into a logfile from a script, I'm noticing the time never changes.
Here's an example of the resulting log entries:
12/29/2006 13:15:47: www_data compressed.
12/29/2006 13:15:47: Database dump done.
12/29/2006 13:15:47: Checksums created.
12/29/2006 13:15:47: Other stuff done.
12/29/2006 13:15:47: Sending files to remote server...
12/29/2006 13:15:47: Files sent.
Here's the code snippet that defines the date format:
DATE=`date +'%m/%d/%Y %H:%M:%S'`
Here's the actual code snippets in the script that echo the $DATE into the log:
echo "$DATE: www_data compressed." >> www_backup.log
echo "$DATE: Database dump done." >> www_backup.log
echo "$DATE: Checksums created." >> www_backup.log
...etc...
Is there a reason the time isn't updated when the script runs? I'm guessing here that the
$DATE variable grabs the current time when the script kicks off and doesn't update it in
real-time as the script proceeds - would that be a close guess?
What would need to be changed in order for the current time to be entered into the logfile?
Any assistance would be most appreciated.
Kev
More information about the talk
mailing list