What's new

Scheduling rebooting??

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

What about if I want 2 reboots in one day, one at 00:05 and another at 06:05, should I create 2 separate scripts for it?
 
What about if I want 2 reboots in one day, one at 00:05 and another at 06:05, should I create 2 separate scripts for it?
Hi,

You need two entries in the crontab, but they can call the same script as it will be on different time in the day. :rolleyes:

With kind regards
Joe :cool:
 
You're missing the point: main power reboot is not good for attached USB devices. You need a clean software reboot that unmounts the drives attached.

For anyone interested, I needed it to have my 3G connection reestablished twice a day: once at 00:10 and second at 06:50 for my happy night traffic option :).
I choose to reboot it because I did not know the command for wan reconnect. My script looks like this:

#!/bin/sh
/usr/sbin/cru a ScheduledReboot "10,50 0,6 * * * reboot"
 
Actually, here's an easy way for you to create that schedule.

1) Enable JFFS + Format JFFS + Telnet on the Administration -> System page, then reboot.
2) Download the software called Putty (should be easy to find on Google)
3) Using Putty, connect using the Telnet protocol to your router's IP (probably 192.168.1.1) Username and password are the same as for the webui.
4) Type the following, one line at a time:

Code:
cat << EOF > /jffs/scripts/services-start
#!/bin/sh
/usr/sbin/cru a ScheduledReboot "0 6 * * * reboot"
EOF

Set 0 (minutes) and 6 (hour) to the desired reboot time, for a daily reboot. Those arguments are:

"min hour day month week command"

After this you will be back to the prompt. Now run this:

Code:
chmod a+rx /jffs/scripts/services-start
/jffs/scripts/services-start

That will set up the cron job. Every time you reboot the router, the reboot task will be re-established.

To remove the task:

Code:
rm /jffs/scripts/services-start
cru d ScheduledReboot

Okay, this seems straight forward but something isn't working right for me. When I Telnet in I am at admin@RT-N66U:/tmp/home/root# and I have typed these commands and I have also copied them in but I also get the error
sh: can't create /jffs/scripts/services-start: nonexistent directory

I'm new to this and I have been trying to read/search but am I missing something? I can find the jffs directory, I can see the services-start script, what am I doing wrong?
 
Okay, this seems straight forward but something isn't working right for me. When I Telnet in I am at admin@RT-N66U:/tmp/home/root# and I have typed these commands and I have also copied them in but I also get the error
sh: can't create /jffs/scripts/services-start: nonexistent directory

I'm new to this and I have been trying to read/search but am I missing something? I can find the jffs directory, I can see the services-start script, what am I doing wrong?

http://forums.smallnetbuilder.com/showthread.php?t=14662
 
Yes, this is possible, allthough it's really not necessary! :)
For me, it might be necessary. I was having extremely slow LAN speeds (~200 KB/s instead of the proper ~2.5 MB/s). A reboot fixed it. That's why I searched on how to automate reboots, because I'll take a hammer to this router before I make myself a slave to rebooting it manually. (Sarcastic comments that we should do exactly that by monitoring a clock notwithstanding.)

I got this error:

-sh: can't create /jffs/scripts/services-start: nonexistent directory
I got that error when using the commands above. It worked when I simply surrounded the first EOF with single quotes. That is, instead of this:

Code:
cat << EOF > /jffs/scripts/services-start
I used this:

Code:
cat << 'EOF' > /jffs/scripts/services-start
After you're done, you should be able to execute the following command and see "services-start" listed as output (meaning the file exists):

Code:
ls /jffs/scripts

And finally, submitting the command below should show your cron job:

Code:
cru l
(That's a lower case "L")
 
Actually, here's an easy way for you to create that schedule.

1) Enable JFFS + Format JFFS + Telnet on the Administration -> System page, then reboot.
2) Download the software called Putty (should be easy to find on Google)
3) Using Putty, connect using the Telnet protocol to your router's IP (probably 192.168.1.1) Username and password are the same as for the webui.
4) Type the following, one line at a time:

Code:
cat << EOF > /jffs/scripts/services-start
#!/bin/sh
/usr/sbin/cru a ScheduledReboot "0 6 * * * reboot"
EOF

Set 0 (minutes) and 6 (hour) to the desired reboot time, for a daily reboot. Those arguments are:

"min hour day month week command"

After this you will be back to the prompt. Now run this:

Code:
chmod a+rx /jffs/scripts/services-start
/jffs/scripts/services-start

That will set up the cron job. Every time you reboot the router, the reboot task will be re-established.

To remove the task:

Code:
rm /jffs/scripts/services-start
cru d ScheduledReboot

Thank you for the example on how to set up a cron job! But being a beginner in scripting language, I still have 2 specific questions:

1) when I try to setup a cron job so my RT-N16 (running Merlin's Fw 3.0.0.4.374.36_beta1) would update regularly my dynamic IP at the UnoTelly servers (for vpn streamimg service to access netflix, etc) using the example below (copied from UnoTelly site):

«* /12 * * * root wget http://www.unotelly.com/unodns/auto_auth/hash_update/updateip.php?user_hash=your_token»»

I get this «parse error» from CRON (as indicated at the /tmp/syslog.log):
«Feb 27 17:38:10 crond[329]: user admin: parse error at /12
Feb 27 17:38:10 crond[329]: time disparity of 1661377 minutes detected»

I don't have any experience with Crond, but I googled about it and I suspect this error has to do with the use of the operator «/» (above "*/12" means execute «every 12 hours», i.e., execute only those hours divisible by 12) -- maybe the current Cron daemon version running Merlin's firmware does not support this operator?

If so, how can I setup properly a cron job on RT-N16 like the example below every 10 or 12 hours?

Here's my full script fragment:

/usr/sbin/cru a ActualizaUnoTelly "* /12 * * * wget http://www.unotelly.com/unodns/auto_auth/hash_update/updateip.php?user_hash=[ommited]"

Please, note, that I ommited «root» and that I encapsulated between " " everything starting from cron parameters * * * * till the end. But not sure whether I'm wright or wrong here...

2) Or maybe I am not picking the proper Merlin's script for a cron job to run -- I inserted the above fragment in /jffs/script/services-start... Maybe I should use another one, like «init-start» or else..?
Many thanks in advance for your help!
João
 
Actually, here's an easy way for you to create that schedule.

1) Enable JFFS + Format JFFS + Telnet on the Administration -> System page, then reboot.
2) Download the software called Putty (should be easy to find on Google)
3) Using Putty, connect using the Telnet protocol to your router's IP (probably 192.168.1.1) Username and password are the same as for the webui.
4) Type the following, one line at a time:

Code:
cat << EOF > /jffs/scripts/services-start
#!/bin/sh
/usr/sbin/cru a ScheduledReboot "0 6 * * * reboot"
EOF

Set 0 (minutes) and 6 (hour) to the desired reboot time, for a daily reboot. Those arguments are:

"min hour day month week command"

After this you will be back to the prompt. Now run this:

Code:
chmod a+rx /jffs/scripts/services-start
/jffs/scripts/services-start

That will set up the cron job. Every time you reboot the router, the reboot task will be re-established.

To remove the task:

Code:
rm /jffs/scripts/services-start
cru d ScheduledReboot



I think it should be as follows:

he time and date fields are:

field allowed values
-----

--------------

minute

0-59

hour

0-23

day of month

1-31

month

1-12 (or names, see below)

day of week

0-7 (0 or 7 is Sun, or use names)
A field may be an asterisk (*), which always stands for "first-last".
 
So far I always refused to implement a webui interface to schedule reboots because if I do, then someone will ask to make the scheduling more flexible to support two different scheduled reboots. Then someone else will ask for multiple reboot schedules. Then, someone else will ask for the feature allowing him to run a script before doing the reboot. And so on... Since I want to avoid feature bloat in my firmware, I decided to leave it to users to do it through scripting. I'm sure someone will be able to guide you through the details on how to do it - it's simpler than you might think. :)

Love this firmware and I put it on all the ASUS routers that I support.

Wish the scheduled reboot scripts would survive the firmware updates. Not a big deal for just one router but when you have a lot of them it becomes time consuming to rebuild the scripts.

Keep up the great work!
 
I would like to +1 the request for GUI based scheduled rebooting.

This is immensely useful for those who are not computer-savvy, who do not want to make mistakes fooling around with JFFS and cron (which is like 99% of the people I set up networks for).

In practice, weekly or even daily rebooting can really help with real-world issues. Astaro did not think so and see where that got them.

Scheduled reboot feature is the ONLY reason why I have to leave Asuswrt-Merlin for other firmware like dd-wrt and Tomato.
 
What would the script be for a nightly reboot?

I have two AC68U routers and one becomes non-responsive every 2-3 days. A nightly reboot will eliminate this issue.

thanks!
 
I followed this advice to the letter--multiple times--and never managed to get my router to reboot on a schedule.
 
I followed this advice to the letter--multiple times--and never managed to get my router to reboot on a schedule.

Post here the following outputs
Code:
cru l
Code:
cat /jffs/scripts/services-start
Code:
ls -l /jffs/scripts
 
Hi!
Is it possible using script to reboot the connection of 4G USB-modem (on WAN №2) on schedule (without rebooting the router), for example, every day at 00:01 (AC68U Firmware: 376.48_1)? Thanks.
 
Hi!
Is it possible using script to reboot the connection of 4G USB-modem (on WAN №2) on schedule (without rebooting the router), for example, every day at 00:01 (AC68U Firmware: 376.48_1)? Thanks.

That's what I'm interested in.

Is there a way the USB modem with a script every day to start at 5:00
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

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