get the timestamp as a log filename

Alexander Dalloz alexander.dalloz at uni-bielefeld.de
Fri Jan 23 18:10:20 UTC 2004


Am Fr, den 23.01.2004 schrieb Tom Mitchell um 18:51:

[ snip ]


> > > 	mv logfile.1 logfile-ending-on-`date +"%Y-%m-%d_%R`
> 
> I need to think about how your script interacts with the log daemon
> and logrotate.  Processes that log to files often keep the file open
> thus the mv is done first.  Then a new file is created if needed.
> Then the process is signaled so it can close the old file's inode.
> The rename acts on the inode that is open.  If you make a copy of a
> file that is open it only contains the data at that instant.  I think
> there is a small window of time where some stuff can be lost in your
> solution.

Yes, that is _very_ critical. So my (wild) suggestion before was already
not a simple move but a copy and then to empty the original logfile (>
logfile). The syslog daemon massively dislikes it if you take him away
the logfile. He just will stop to log until you restart him. So just a
file move is worst you can do.

Alexander


-- 
Alexander Dalloz | Enger, Germany
PGP key valid: made 13.07.1999
PGP fingerprint: 2307 88FD 2D41 038E 7416  14CD E197 6E88 ED69 5653





More information about the fedora-list mailing list