[SOLVED] Restart OpenVPN via Cron Every Night



  • Hello, I have 2 OpenVPN servers setup and 2 OpenVPN clients setup. I would like cron to restart ovpnc2 cleint interface every night but I only would like that this interface to restart. Is there a command only target that one openvpn client?

    I found this command listed but I would guess that it restarts all the open servers and cleints?

    #!/usr/local/bin/php -q


  • Rebel Alliance Developer Netgate

    Here's the easiest way:

    First find the server you need to restart:

    : ps uxawww | grep openvpn
    root    25984 0.0  0.9 13496  4340  ??  Ss  Thu06PM  0:09.08 /usr/local/sbin/openvpn –config /var/etc/openvpn/server1.conf
    root    32393  0.0  0.9 13496  4492  ??  Ss  Thu06PM  0:01.75 /usr/local/sbin/openvpn –config /var/etc/openvpn/server2.conf

    Then run this script to restart just that one

    : /usr/local/sbin/pfSsh.php playback svc restart openvpn server 1

    Starting the pfSense shell system…............

    Attempting to issue restart to openvpn service...

    openvpn has been restarted.

    Note that only server 1 restarted:

    : ps uxawww | grep openvpn
    root    32393  0.0  0.9 13496  4492  ??  Ss  Thu06PM  0:01.75 /usr/local/sbin/openvpn –config /var/etc/openvpn/server2.conf
    root    32933  0.0  0.9 13496  4624  ??  Ss    4:18PM  0:00.00 /usr/local/sbin/openvpn –config /var/etc/openvpn/server1.conf



  • Perfect! Thanks jimp!