[nycbug-talk] Scripting(Date&Time) Question

Okan Demirmen okan at demirmen.com
Fri Dec 29 14:01:21 EST 2006


On Fri 2006.12.29 at 13:41 -0500, michael wrote:
> On Fri, 29 Dec 2006 13:32:56 -0500
> Kevin Reiter <tux at penguinnetwerx.net> wrote:
> 
> > 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
> 
> At first blush, it looks like you only initialize $DATE once at the
> start.  So.. your assumption looks right from here.

yes.



More information about the talk mailing list