I have a script running in the background that prints some output. I redirected the standard output to a file for log purposes. However I don't want this file to grow forever, what would be a good way to do rollover without coding the logic myself? (Either rollover based on date or file size).
This depends on the logging program to close and reopen the log after it is rotated.
Craig
2009-09-18 18:33:41
`logrotate` can send a signal to the program which can trap and handle it. Easy enough.
Dennis Williamson
2009-09-18 19:30:29
+5
A:
Pipe the output into something like multilog it will handle all that stuff for you.
And example:
script_that_produces_output.sh |multilog s2000 ./logdir
will run the script capturing stdout to a file called ./logdir/current
rotating it when it is bigger than 2000 bytes.
Craig
2009-09-18 18:32:22