[CentOS] Log rolling with a daemon

Larry Martell larry.martell at gmail.com
Sun Dec 22 00:56:00 UTC 2013


I'm looking for advice or suggestions for rolling log files with a
daemon. I have a python script that I daemonized with
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/.
Before I daemonized it it was run from a bash script that invoked the
underlying python script. It ran the python script, waited for it to
complete and then it slept for 5 seconds and ran it again. This was in
a infinite loop. In between each invocation it checked the log file
and if it was over 10MB it renamed it and then the next invocation
started with a new empty log. Since each invocation was a separate run
this worked fine.  But now the daemonized python script doesn't exit -
the same log file is attached to it forever. So my renaming of the
file does nothing - the i node doesn't change and it's still logging
to the same large file. Anyone have any ideas how I can achieve this
sort of log rolling in this situation?

TIA!
-lrry



More information about the CentOS mailing list