openvpn 로그 회전

openvpn 로그 회전

저는 OpenVPN 로그 파일을 매달 교체하려고 합니다. 문제는 단순히 파일 이름을 바꾸는 것만으로는 문제가 해결되지 않는다는 것입니다. 데이터는 여전히 이전 파일에 기록됩니다(이는 로그 파일이 계속 열려 있고 로그 레코드가 여전히 이전 파일 개체에 기록됨을 나타냅니다).

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

그러나 이 스크립트에는 버그가 있는 것으로 보이며 서버를 올바르게 시작하지 못하는 경우도 있습니다(tun0이 종료되는 경우도 있음).

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

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

답변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

시스템 로그에 로그인하는 방법은 무엇입니까?

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

관련 정보