I have an VPN that I'd like to be on all time. The VPN is an OpenVPN type and was set up and used via the VPN software Tunnelblick. For some unknown reason, the VPN connection or the Tunnelblick process tend to run into a bad state after the VPN has been on for long time, say a day. I'd like to set up a cron job, so it is restarted every night. How to do this?

OS: macOS Sierra 10.12

  • What stops you from trying? – techraf Sep 29 '16 at 4:37

Write an AppleScript oneliner per the official TunnelBlick documentation:

osascript -e "tell application \"Tunnelblick\"" -e "connect \"configuration-name\"" -e "end tell"

And set it as a cron job.

  • Running osascript -e "tell application Tunnelblick" -e "disconnect \"my-vpn\"" -e "end tell" from my bash command line gave me error: 40:41: syntax error: Expected end of line but found “"”. (-2741) in macOS Sierra + iTerm2. – qazwsx Sep 29 '16 at 20:19
  • Add quotes around TunnelBlick. – techraf Sep 29 '16 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.