How to reconnect an OpenVPN VPN set by Tunnelblick automatically in a cron job?

0

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

qazwsx

Posted 2016-09-29T04:30:39.243

Reputation: 6 739

What stops you from trying? – techraf – 2016-09-29T04:37:16.210

Answers

0

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.

techraf

Posted 2016-09-29T04:30:39.243

Reputation: 4 428

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 – 2016-09-29T20:19:35.530

Add quotes around TunnelBlick. – techraf – 2016-09-29T21:41:19.670