티스토리 뷰

1분 주기로 haproxy 로그 확인해서 100M 넘으면 로테이트해서 500개 까지 보관(crontab 사용하지 않고, /etc/cron.d 설정)

mkdir /etc/logrotate.hourly

cat <<EOF > /etc/logrotate.hourly/haproxy
/var/log/haproxy/haproxy.log
/var/log/haproxy/haproxy-*.log {
  hourly
  missingok
  nocompress
  notifempty
  size 100M
  rotate 500
  dateext
  dateformat -%Y%m%d%H-%s
  #copytruncate
  postrotate
    /usr/bin/pgrep rsyslogd | xargs -I{} kill -s HUP {}
  endscript
}
EOF

mkdir /etc/cron.minutely

cat <<EOF > /etc/cron.minutely/0logrotate.hourly
/usr/sbin/logrotate  /etc/logrotate.hourly/haproxy
EOF

chmod 750 /etc/cron.minutely/0logrotate.hourly
 
cat <<EOF > /etc/cron.d/0minutely
# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
* * * * * root run-parts /etc/cron.minutely
EOF

chmod 640 /etc/cron.d/0minutely

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
페이지
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함