What's new

Cron job to reset VPN in slot 1

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Viktor Jaep

Part of the Furniture
Hi All,

I'll admit... I'm just not good at this scripting stuff... but what I am looking for is your help/advice on what it would take to automatedly run a cron job at a specific time each night to simply stop/start or restart the VPN client in slot/instance #1.

I figured out that the cron script piece would need to say: 0 01 * * 1-7 -- executing at 01:00 every day of the week... but I'm not sure what script (if any) relating to VPN slot #1 I could execute in order for this to happen, or if it would need to be created?

I appreciate your help, and I appreciate the learning opportunity here! Thank you in advance...
 
Using "1-7" for days is non-standard and therefore bad practice. days should range from 0 to 6, but as you want "all days" you might as well use "*" instead.

I can't help you with the VPN command though. :(
 
Using "1-7" for days is non-standard and therefore bad practice. days should range from 0 to 6, but as you want "all days" you might as well use "*" instead.

LOL.. thanks! So much for being proactive and using the Crontab expression editor! :)
 
LOL.. thanks! So much for being proactive and using the Crontab expression editor! :)
Ha! I've been doing crontab entries for over 20 years. It's burnt into my brain. :) (To be fair that website does say in red that your command was "Non standard! May not work with every cron." )
 
Last edited:
Does this do what you want if you enter it from the command line?
Code:
service restart_vpnclient1

Yes, thanks -- that does the trick! So is it just a matter of running a command like:

0 01 * * * /jffs/scripts/service restart_vpnclient1

??

And this will survive a reboot, right?
 
And this will survive a reboot, right?
No you have to use the cru command and put it in a user script.

Add the following line to the end of your /jffs/scripts/services-start script (assuming it already exists).
Code:
cru a vpn1 "00 01 * * * service restart_vpnclient1"
 
No you have to use the cru command and put it in a user script.

Add the following line to the end of your /jffs/scripts/services-start script (assuming it already exists).
Code:
cru a vpn1 "00 01 * * * service restart_vpnclient1"

Thanks a bunch, Colin! That was super helpful! Learned all about how VI is very unuserfriendly, and how nano was much easier to edit files with too... ;) I really appreciate this... will check the logs tomorrow AM and see how it fared!
 
BTW you do have to reboot the router for that services-start script to run. ;)

Ahh. I was trying to figure out why nothing happened at 1am according to the logs... ;) Good call... it's been rebooted now... let's see what happens tomorrow!
 
You can check that the services-start has run correctly by looking at the router's crontab. Enter the following command and you should see your entry:
Code:
cru l
(That's a lower case letter "L" not a number "1")
 

Similar threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top