Is there a way using logrotate I can rotate entire directory and compress it instead of just the files in a particular directory? I tried experimenting using the config below but that does not work. Give the error message below:
Config:
/path/to/folder/test {
daily
rotate 5
missingok
compress
delaycompress
}
Error:
$logrotate -vf test.conf
reading config file test.conf
reading config info for /path/to/folder/test
Handling 1 logs
rotating pattern: /path/to/folder/test forced from command line (5
rotations)
empty log files are rotated, old logs are removed
error: error creating unique temp file: Permission denied
The main logrotate configuration file is located at /etc/logrotate. conf . The file contains the default parameters that logrotate uses when it rotates logs.
If you want to force Logrotate to rotate the log file when it otherwise would not have, use the --force flag: logrotate /home/sammy/logrotate. conf --state /home/sammy/logrotate-state --verbose --force.
missingok : If the log file is missing, go on to the next one without issuing an error message. noolddir : Logs are rotated in the same directory the log normally resides in (this overrides the olddir option). daily : Log files are rotated every day.
The delaycompress option makes the compression to delay till the next rotation of the log file. Delaycompress parameter would be useful for the application servers which requires writing to the logs continuously and delay compression for a particular amount of time.
Logrotate only operates upon individual files in directories, not the entire directory as a single entity. The most straight-forward solution would be a cronjob that calls something like gzip on that directory then moves/deletes files as you see fit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With