1 logrotate
sysklogd 가 제어하지 않는 로그를 뱅글뱅글 돌리자.1.1 emerge
emerge logrotate
1.2 cron
하루에 한번 cron 에 의해 실행되도록 한다.mkdir /etc/logrotate.d vi /etc/cron.daily/logrotatesh #!/bin/sh /usr/sbin/logrotate /etc/logrotate.d :wq chmod 700 /etc/cron.daily/logrotatesh
1.3 setting
- 실제 실행될 설정파일. 요점은 로테이트 시킬 로그파일 지정과 로그를 돌린 후 서버의 재시동이다.
- /etc/logrotate.d 에 root.root 600 의 파일로 만든다.
- 예문에 나온것들은 로그용량이 50MB 를 넘기면 교체하도록 되어있다.
- 로그는 10개까지 생성된다.
로그가 도는 모습 예
cd /var/log/apache2 ls -al -rw-r--r-- 1 root root 910 2003-06-09 03:00 access_log -rw-r--r-- 1 root root 51034152 2003-06-09 03:00 access_log.1 -rw-r--r-- 1 root root 64837231 2003-06-08 03:00 access_log.2 -rw-r--r-- 1 root root 57362834 2003-06-07 03:00 access_log.3 -rw-r--r-- 1 root root 58374943 2003-06-06 03:01 access_log.4 -rw-r--r-- 1 root root 79382834 2003-06-05 03:00 access_log.5 -rw-r--r-- 1 root root 56384926 2003-06-03 03:01 access_log.6 -rw-r--r-- 1 root root 53823232 2003-06-01 03:00 access_log.7 -rw-r--r-- 1 root root 52344223 2003-05-26 03:00 access_log.8 -rw-r--r-- 1 root root 54392345 2003-05-19 03:00 access_log.9
apache2
/var/log/apache2/access_log /var/log/apache2/error_log /var/log/apache2/ssl_access_log /var/log/apache2/ssl_error_log /var/log/apache2/ssl_request_log {
size=50000k
rotate 10
missingok
notifempty
postrotate
/usr/sbin/apache2ctl graceful compress
Old versions of log files are compressed with gzip by default.
See also nocompress.
endscript
}
mysql
/var/log/mysql/mysql.log /var/log/mysql/mysql.err {
size=50000k
rotate 10
missingok
notifempty
postrotate
/usr/bin/mysqladmin refresh -uroot -pmysqlpassword
endscript
}
qmail
/var/log/qmail/qmail-smtpd/current /var/log/qmail/qmail-send/current {
size=50000k
rotate 10
missingok
notifempty
postrotate
/usr/bin/svc -t /service/qmail-s*
endscript
}
2 응용
매일같이 DB를 백업하되 열흘분만 남긴다.mysql_db_backup
/yourmysqldbbackupdirectory/all_databases.sql {
size=1
rotate 10
missingok
notifempty
postrotate
/usr/bin/mysqldump --all-databases > /yourmysqldbbackupdirectory/all_databases.sql
endscript
}
3 질문과 답변
4 잡담
- 압축만 되면 더이상 바랄게 없습니다. -송효진
옵션중에 compress 란것이 있습니다. logrotate(8) 페이지를 참고. -- mithrandir
[이 게시물은 관리자님에 의해 2011-10-31 17:32:05 Linux에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 1030 | 18년 전 | 1774 | ||
| 1029 | 18년 전 | 2204 | ||
| 1028 | 18년 전 | 2623 | ||
| 1027 | 18년 전 | 1781 | ||
| 1026 | 18년 전 | 1512 | ||
| 1025 | 18년 전 | 1528 | ||
| 1024 | 18년 전 | 1456 | ||
| 1023 | 18년 전 | 3216 | ||
| 1022 | 18년 전 | 2907 | ||
| 1021 | 18년 전 | 1664 | ||
| 1020 | 18년 전 | 3404 | ||
| 1019 | 18년 전 | 1832 | ||
| 1018 | 18년 전 | 1482 | ||
| 1017 | 18년 전 | 1941 | ||
| 1016 | 18년 전 | 2089 | ||
| 1015 | 18년 전 | 1622 | ||
| 1014 | 18년 전 | 2336 | ||
| 1013 | 18년 전 | 1991 | ||
| 1012 | 18년 전 | 1600 | ||
| 1011 | 18년 전 | 1779 | ||
| 1010 | 18년 전 | 2031 | ||
| 1009 | 18년 전 | 1790 | ||
| 1008 | 18년 전 | 1592 | ||
| 1007 | 18년 전 | 1650 | ||
| 1006 | 18년 전 | 3122 | ||
| 1005 | 18년 전 | 1986 | ||
| 1004 | 18년 전 | 1858 | ||
| 1003 | 18년 전 | 4362 | ||
| 1002 | 18년 전 | 4987 | ||
| 1001 | 18년 전 | 3154 | ||
| 1000 | 18년 전 | 2900 | ||
| 999 | 18년 전 | 3491 | ||
| 998 | 18년 전 | 2034 | ||
| 997 | 18년 전 | 2382 | ||
| 996 | 18년 전 | 2680 | ||
| 995 | 18년 전 | 2750 | ||
| 994 | 18년 전 | 2341 | ||
| 993 | 18년 전 | 1605 | ||
| 992 | 18년 전 | 3369 | ||
| 991 | 18년 전 | 1969 | ||
| 990 | 18년 전 | 2376 | ||
| 989 | 18년 전 | 2446 | ||
| 988 | 18년 전 | 2874 | ||
| 987 | 18년 전 | 5206 | ||
| 986 |
|
18년 전 | 2481 | |
| 985 |
|
18년 전 | 3323 | |
| 984 | 18년 전 | 4271 | ||
| 983 |
느낌좋은날
|
18년 전 | 2492 | |
| 982 | 18년 전 | 2457 | ||
| 981 | 18년 전 | 4031 | ||
| 980 | 18년 전 | 2744 | ||
| 979 |
Sinpre
|
19년 전 | 2982 | |
| 978 | 19년 전 | 2196 | ||
| 977 | 19년 전 | 2213 | ||
| 976 | 19년 전 | 1989 | ||
| 975 | 19년 전 | 3269 | ||
| 974 | 19년 전 | 2102 | ||
| 973 |
|
19년 전 | 2777 | |
| 972 |
|
19년 전 | 1736 | |
| 971 | 19년 전 | 5307 | ||
| 970 | 19년 전 | 3558 | ||
| 969 | 19년 전 | 4311 | ||
| 968 | 19년 전 | 3053 | ||
| 967 | 19년 전 | 2520 | ||
| 966 | 19년 전 | 3915 | ||
| 965 | 19년 전 | 2639 | ||
| 964 | 19년 전 | 2984 | ||
| 963 | 19년 전 | 2951 | ||
| 962 | 19년 전 | 4172 | ||
| 961 | 19년 전 | 3120 | ||
| 960 | 19년 전 | 3015 | ||
| 959 | 19년 전 | 3665 | ||
| 958 | 19년 전 | 2965 | ||
| 957 | 19년 전 | 2189 | ||
| 956 | 19년 전 | 2217 | ||
| 955 | 19년 전 | 2156 | ||
| 954 | 19년 전 | 2762 | ||
| 953 | 19년 전 | 2469 | ||
| 952 | 19년 전 | 3335 | ||
| 951 | 19년 전 | 3186 | ||
| 950 | 19년 전 | 1817 | ||
| 949 | 19년 전 | 2735 | ||
| 948 | 19년 전 | 7818 | ||
| 947 |
|
19년 전 | 2490 | |
| 946 |
DeepnBlue
|
19년 전 | 3096 | |
| 945 |
pearly
|
19년 전 | 2847 | |
| 944 | 19년 전 | 3010 | ||
| 943 |
|
19년 전 | 2210 | |
| 942 | 19년 전 | 2446 | ||
| 941 |
|
19년 전 | 4067 | |
| 940 | 19년 전 | 2226 | ||
| 939 |
|
19년 전 | 4215 | |
| 938 |
|
19년 전 | 2375 | |
| 937 | 19년 전 | 2071 | ||
| 936 |
|
19년 전 | 2320 | |
| 935 | 19년 전 | 1863 | ||
| 934 |
|
19년 전 | 2395 | |
| 933 | 19년 전 | 2187 | ||
| 932 |
|
19년 전 | 3059 | |
| 931 | 19년 전 | 1844 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기