24 hours Restart Cronjob
with this cronjob + my openvpn commands (from the ovpn-file other topic link below) you can use your VPN-Connection from your VPN-Provider all the time and change the location automatically how often you like!
It’s very simple: your router will check if the connection is lost and reconnect automatically if there is no connection with the ovpn-file and some VPN-Provider don’t allow a permanent connection, therefor this cronjob below do a vpn restart every 24 hours that will give you the option to change the location too;)
-> Plus optional: cronjob router restart, if you want to do this too, for whatever reason.
Below you find two scripts. A script for listening and restart to stay the day only (so therefore no ovpn-file change needed) and a script for setting a time to make a manual restart ( if you don’t want to use this cronjob)
If you are a new vpn-user, you can check my tutorial how to connect to your vpn provider with ovpn-file: HowToOpenVPNClient
Go into Terminal (Linux) and write:
->hit enter and use your forris/luci passwort
- To set up a cronjob, use this first:
- Write this code in it (Restart of vpn everyday at 3:30am)
30 3 * * * /etc/init.d/openvpn stop ; /etc/init.d/openvpn start
If you want you can add a second line to restart your router 1 time in the year Or more often, do what you want!
* * 1 1 * sleep 70 && touch /etc/banner && reboot
- You can set your times by yourself, here you see the timetable:
* * * * * command to be executed - - - - - | | | | | | | | | +----- day of week (0 - 6) (Sunday=0) | | | +------- month (1 - 12) | | +--------- day of month (1 - 31) | +----------- hour (0 - 23) +------------- min (0 - 59)
- A few other commands, which may or may not be necessary, to ensure that cron was running:
/etc/init.d/cron start /etc/init.d/cron enable /etc/init.d/cron restart
You can actually interact with cron through the web panel as well and check if the settings are saved > System > Scheduled tasks.
With “Remote-Random” at stop & start of openvpn your router will choose a random remote server from your ovpn-file like you can see here: HowToOpenVPNClient
-> With this two tutorials now your connection should be stable all the time and with location change and router restart like you want it. If not, check the post below! Don’t forget to enable openvpn on router restart and only allow vpn internet access like in the other script!