# logrotate script. Called once at the end of each month. You may want to write a # config script for each server that needs sorting out; NOT for each service! # How often to do this... # At the moment: monthly will rename file xxx to xxx.YYYYMM # Doesn't matter if this is run at the end of a month or just over the beginning, # it's smart enough to work that out. Just run it near midnight on the changeover. period monthly # Do we wait for midnight before sending the signal? # (Use if calling this before the month ticks over) midnight yes # There may be multiple kill lines. In this case, signals are sent to each identified process. # For example, we may wish to sighup a whois++ daemon too. kill USR1 /usr/local/apache/logs/httpd.pid # The logfiles to rotate. Each of these is moved (renamed) according to the # scheme above. Once this is done, the processes are sent appropriate signals. # If the mv target exists, the current log target gets 01, 02, etc. appended to it # If the mv still fails for some reason, errors are produced to standard out. # After we send the signals, we may wish to modify the old logfiles. # in this case, we compress them all. To leave them alone, use "none" as the method. logfile gzip /usr/local/apache/logs/access_log logfile gzip /usr/local/apache/logs/error_log logfile gzip /home/jan/ioctl.org/logs/access_log logfile gzip /home/jan/ioctl.org/logs/error_log # Disposition after the signal(s) are sent: wait for... # 1. a set time "wait sleep " # 2. the files to be closed for output by everything "wait fuser t1 t2" or "wait lsof t1 t2" # In the latter case, we call fuser or lsof to determine which processes (if any) # are still attempting to write to the file. This'll cause problems if we want # to zip them, for instance. If files are still open after t2 seconds, we don't # postprocess them but we do signal an error. wait fstat 10 600 # To recap, the logrotate script: # 1. moves the logfiles. # 2. signals the server(s). # 3. waits for the files to have been closed. # 4. (optionally) postprocesses some or all of the logfiles further: only if not closed!