openvpn 로그 회전

openvpn 로그 회전

매달 OpenVPN 로그 파일을 교체하려고 합니다. 문제는 단순히 파일 이름을 바꾸는 것만으로는 효과가 없다는 것입니다. 데이터는 여전히 이전 파일에 기록됩니다. 이는 로그 파일이 열린 상태로 유지되고 로깅이 여전히 이전 파일 객체에 기록됨을 나타냅니다.

이제 새 로그 파일 위치에 대한 심볼릭 링크를 업데이트한 후 매달 초에 openvpn을 다시 시작하는 스크립트를 작성했습니다.

그러나 이 스크립트는 버그가 있는 것으로 보이며 때때로 서버를 올바르게 시작하지 못합니다(tun0이 때때로 다운됨).

그래서 OpenVPN에서 로그 회전을 달성하는 더 좋은 방법을 알고 계신 분이 있는지 묻고 싶습니다.

편집하다: 저는 Debian Squeeze를 사용하고 있고 재시작 스크립트는 이미 ovpn서버 를 중지하고 시작하는 사이에 5초 동안 휴면 상태입니다.

답변1

이 상황을 처리하는 방법에는 두 가지가 있습니다. 신호를 통해 또는 지시문을 통해 프로세스를 다시 시작하여 logrotate가 프로세스에 알리도록 하는 이상적인 방법입니다 postrotate. 다른 방법은 copytruncate. 이 copytruncate방법은 귀하의 상황에 적합해야 합니다. 문서의 설명은 다음과 같습니다.

   copytruncate
          Truncate  the  original log file in place after creating a copy,
          instead of moving the old log file and optionally creating a new
          one,  It  can be used when some program can not be told to close
          its logfile and thus might continue writing (appending)  to  the
          previous log file forever.  Note that there is a very small time
          slice between copying the file and truncating it, so  some  log-
          ging  data  might be lost.  When this option is used, the create
          option will have no effect, as the old log file stays in  place.

답변2

syslog에 로그인하는 해결 방법은 어떻습니까?

( 의 사용법 --daemon [progname](또는 )을 참조하십시오 .--syslog [progname]man openvpnhttp://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html)

관련 정보