What's new

VPN on/off via cron script

  • 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!

There is nothing to show. It doesn’t have any tasks whatsoever.

HOWEVER, when I run the command below manually


cru a vpnup "30 10 * * FRI,SAT,SUN,MON sh /jffs/scripts/vpnon.sh"


THEN I run cru l, shows this:


30 10 * * FRI,SAT,SUN,MON sh /jffs/scripts/vpnon.sh #vpnup

That’s it.

Then I reboot the router, again no tasks show when cru l UNLESS I rerun the command;


cru a vpnup "30 10 * * FRI,SAT,SUN,MON sh /jffs/scripts/vpnon.sh"
 
Last edited:
There is nothing to show. It doesn’t have any tasks whatsoever.

HOWEVER, when I run the command below manually


cru a vpnup "30 10 * * FRI,SAT,SUN,MON sh /jffs/scripts/vpnon.sh"


THEN I run cru l, shows this:


30 10 * * FRI,SAT,SUN,MON sh /jffs/scripts/vpnon.sh #vpnup

That’s it.

Then I reboot the router, again no tasks show when cru l UNLESS I rerun the command;


cru a vpnup "30 10 * * FRI,SAT,SUN,MON sh /jffs/scripts/vpnon.sh"
Just doublechecking... but you called it "services-start", and it's located under /jffs/scripts, correct?
 
Just doublechecking... but you called it "services-start", and it's located under /jffs/scripts, correct?
Yes. I created a file named services-start and put the task in it and yes, it is in jffs/scripts/
 

Attachments

  • 334FEDD4-D746-48B3-A33F-E58C59B66919.jpeg
    334FEDD4-D746-48B3-A33F-E58C59B66919.jpeg
    41.3 KB · Views: 63
Yes. I created a file named services-start and put the task in it and yes, it is in jffs/scripts/
Perhaps the services-start isn't executable... Try running this command...

Code:
chmod +x /jffs/scripts/services-start

Then try rebooting your router and see if it populates your cru task list by running "cru l"?
 
YES! It works now!!!
Thanks man! I really appreciate your patience with me. After the chmod command, it works now!
 
Last edited:
YES! It works now!!!
Thanks man! I really appreciate your patience with me. After the chmod command, it works now!
You're welcome! Glad it works. Gotta love automation, right? ;)
 
OK. I am spoiled

If I did more specific, would this script be correct?


#!/bin/sh
cru a vpnup "45 11 * * MON sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * MON sh /jffs/scripts/vpnoff.sh"

#!/bin/sh
cru a vpnup "02 15 * * TUE,WED sh /jffs/scripts/vpnon.sh"
cru a vpndown "15 17 * * TUE,WED sh /jffs/scripts/vpnoff.sh"

#!/bin/sh
cru a vpnup "30 12 * * THU sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * THU sh /jffs/scripts/vpnoff.sh"

#!/bin/sh
cru a vpnup "45 11 * * FRI sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * FRI sh /jffs/scripts/vpnoff.sh"

#!/bin/sh
cru a vpnup "45 10 * * SAT,SUN sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * SAT,SUN sh /jffs/scripts/vpnoff.sh"
 
You should only have #!/bin/sh once on the first line of a script.

You must have unique names for each cru entry. Having multiple copies of vpnup and vpndown means you're just overwriting the previous ones.
 
OK. I am spoiled

If I did more specific, would this script be correct?


#!/bin/sh
cru a vpnup "45 11 * * MON sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * MON sh /jffs/scripts/vpnoff.sh"

#!/bin/sh
cru a vpnup "02 15 * * TUE,WED sh /jffs/scripts/vpnon.sh"
cru a vpndown "15 17 * * TUE,WED sh /jffs/scripts/vpnoff.sh"

#!/bin/sh
cru a vpnup "30 12 * * THU sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * THU sh /jffs/scripts/vpnoff.sh"

#!/bin/sh
cru a vpnup "45 11 * * FRI sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * FRI sh /jffs/scripts/vpnoff.sh"

#!/bin/sh
cru a vpnup "45 10 * * SAT,SUN sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * SAT,SUN sh /jffs/scripts/vpnoff.sh"

Yep, you can actually throw these all together under services-start. You just need one set of #!/bin/sh at the very top of the file. Just remember, the first number is the minutes, the second is the hours. And yes, they need to be uniquely named as Colin said. ;)
 
So something like this?


#!/bin/sh
1)
cru a vpnup "45 11 * * MON sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * MON sh /jffs/scripts/vpnoff.sh"
;;

2)
cru a vpnup "41 15 * * TUE,WED sh /jffs/scripts/vpnon.sh"
cru a vpndown "15 17 * * TUE,WED sh /jffs/scripts/vpnoff.sh"
;;

3)
cru a vpnup "30 12 * * THU sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * THU sh /jffs/scripts/vpnoff.sh"
;;

4)
cru a vpnup "45 11 * * FRI sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * FRI sh /jffs/scripts/vpnoff.sh"
;;

5)
cru a vpnup "45 10 * * SAT,SUN sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * SAT,SUN sh /jffs/scripts/vpnoff.sh"
 
So something like this?


#!/bin/sh
1)
cru a vpnup "45 11 * * MON sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * MON sh /jffs/scripts/vpnoff.sh"
;;

2)
cru a vpnup "41 15 * * TUE,WED sh /jffs/scripts/vpnon.sh"
cru a vpndown "15 17 * * TUE,WED sh /jffs/scripts/vpnoff.sh"
;;

3)
cru a vpnup "30 12 * * THU sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * THU sh /jffs/scripts/vpnoff.sh"
;;

4)
cru a vpnup "45 11 * * FRI sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * FRI sh /jffs/scripts/vpnoff.sh"
;;

5)
cru a vpnup "45 10 * * SAT,SUN sh /jffs/scripts/vpnon.sh"
cru a vpndown "01 15 * * SAT,SUN sh /jffs/scripts/vpnoff.sh"
Nope... they would need to have unique names... like this:

Code:
#!/bin/sh

cru a vpnup1 "45 11 * * MON sh /jffs/scripts/vpnon.sh"
cru a vpndown1 "01 15 * * MON sh /jffs/scripts/vpnoff.sh"
cru a vpnup2 "41 15 * * TUE,WED sh /jffs/scripts/vpnon.sh"
cru a vpndown2 "15 17 * * TUE,WED sh /jffs/scripts/vpnoff.sh"
cru a vpnup3 "30 12 * * THU sh /jffs/scripts/vpnon.sh"
cru a vpndown3 "01 15 * * THU sh /jffs/scripts/vpnoff.sh"
cru a vpnup4 "45 11 * * FRI sh /jffs/scripts/vpnon.sh"
cru a vpndown4 "01 15 * * FRI sh /jffs/scripts/vpnoff.sh"
cru a vpnup5 "45 10 * * SAT,SUN sh /jffs/scripts/vpnon.sh"
cru a vpndown5 "01 15 * * SAT,SUN sh /jffs/scripts/vpnoff.sh"
 
Yep! That’s it!
Thanks guys! I really appreciate the help. Especially you Viktor!
We are all just a big happy nerdy community here, ready to pitch in and help. ;)
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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