Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
home_server:home_server_setup:other_services:logrotate [2022-09-05 Mon wk36 15:42] – baumkp | home_server:home_server_setup:other_services:logrotate [2023-12-26 Tue wk52 11:30] (current) – [Links] baumkp | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{tag> | ||
======logrotate====== | ======logrotate====== | ||
There are a number of ways to rotate logs. | There are a number of ways to rotate logs. | ||
Line 4: | Line 5: | ||
-Using '' | -Using '' | ||
+ | ====Logrotate using script==== | ||
- | <- home_server: | + | edit the sudo crontab '' |
+ | < | ||
+ | Example of job definition: | ||
+ | # .---------------- minute (0 - 59) | ||
+ | # | .------------- hour (0 - 23) | ||
+ | # | | .---------- day of month (1 - 31) | ||
+ | # | | | .------- month (1 - 12) OR jan, | ||
+ | # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun, | ||
+ | # | | | | | | ||
+ | # * * * * * | ||
+ | # 0 0 1 * * / | ||
+ | </ | ||
+ | |||
+ | where ''/ | ||
+ | < | ||
+ | logfile=$1 | ||
+ | if [ ! -f $logfile ]; then | ||
+ | echo "log file not found $logfile" | ||
+ | exit 1 | ||
+ | fi | ||
+ | timestamp=`date +%Y%m%d` | ||
+ | newlogfile=$logfile.$timestamp | ||
+ | cp $logfile $newlogfile | ||
+ | cat /dev/null > $logfile | ||
+ | gzip -f -9 $newlogfile | ||
+ | </ | ||
+ | Remember to make executable ('' | ||
+ | |||
+ | ====logrotate==== | ||
+ | -Install logrotate | ||
+ | - debian: '' | ||
+ | - Arch: '' | ||
+ | *The main logrotate configuration file is here: ''/ | ||
+ | * | ||
+ | |||
+ | ====Links==== | ||
+ | [[https:// | ||
+ | |||
+ | |||
+ | <- home_server: |