I have a long running process, that writes its log file to stdout
. I would like to save this output to different files, automatically maintain these files (like deleting/archiving the old ones), without restarting the main process.
On solution would be to send the output to a file (process > log.txt
), and use logrotate
on it, but logrotate
needs to restart the program, which is not possible.
The other one is to pipe the output to cronolog
(process | cronolog
), but in this case older files won't get deleted / archived, meaning I have to make a program that will do the maintenance for me.
The best would be to be able to use both utilities, because with cronolog
I don't need to restart the process, and logrotate
will maintain the old log files exactly as I want. Is there a way to get these two programs to work with each other? If not, what is a good solution to this problem?