I have a daemon writing to a log file that, eventually, fills up the disk. Is there a way for me to periodically limit the size of the log file without stopping the daemon without changing the code in it? SIGHUP kills the daemon.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The usual trick is:
That would work provided that your daemon properly open the log file in append mode. Most of them do. (That command simply truncates file size to zero and that doesn’t intervene with another process writing to the file in append mode.)
Another option is to check whether your daemon support syslog and activate it. Most Linuxes now are shipped with some log collector which automatically (based on rules, etc) archive syslog files.