Scheduled reboot

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 03:16, 2 November 2022 (edit)
Kernel-panic69 (Talk | contribs)
(Not working as intended - (fix numbering))
← Previous diff
Current revision (03:18, 2 November 2022) (edit) (undo)
Kernel-panic69 (Talk | contribs)
(Alternative without the need of cron - (fix numbering))
 
Line 30: Line 30:
== Alternative without the need of cron == == Alternative without the need of cron ==
-# Go to DD-WRT configuration page+<ol>
-# Disable scheduled reboot in '''Administration -> Keep Alive '''+<li> Go to DD-WRT configuration page
-# '''Administration -> Commands '''+<li> Disable scheduled reboot in '''Administration -> Keep Alive '''
-# Input+<li> '''Administration -> Commands '''
 +<li> Input
- >/tmp/reboot.sh+<pre> >/tmp/reboot.sh
echo 'current_year="1970"'>>/tmp/reboot.sh echo 'current_year="1970"'>>/tmp/reboot.sh
echo 'while [ $current_year -eq 1970 ]'>>/tmp/reboot.sh echo 'while [ $current_year -eq 1970 ]'>>/tmp/reboot.sh
Line 49: Line 50:
echo 'reboot'>>/tmp/reboot.sh echo 'reboot'>>/tmp/reboot.sh
echo '/bin/sh /tmp/reboot.sh &'>/tmp/reboot0.sh echo '/bin/sh /tmp/reboot.sh &'>/tmp/reboot0.sh
- /bin/sh /tmp/reboot0.sh+ /bin/sh /tmp/reboot0.sh</pre>
-# '''Save Startup'''+<li> '''Save Startup'''
-# You can edit this at any time+<li> You can edit this at any time
-# Now reboot the router. It will from now on reboot every day at 4.30 am+<li> Now reboot the router. It will from now on reboot every day at 4.30 am
 +</ol>
[[Category:Scripts]] [[Category:Scripts]]

Current revision

[edit] What it can be used for

Scheduled reboot is often used to give the routers a little clearing now and then to keep its performance at its peak. It can also be used in combination with uPnP with the setting "clear ports at startup" enabled to give the benefits of uPnP without the drawbacks of gaps in your security (for long periods of time anyway).

I find that using a scheduled reboot often gives a brilliant transfer and receive rate for wireless which makes a huge difference when in client mode. The higher to the maximum transfer and receive (whilst assuming no other wireless clients are heavily using it such as downloading) I can receive extremely low ping between my primary router and secondary router - around 1-2 ms average with a distance of around 50 metres set in the ACK timer.

It is necessary for WDS to work as intended. When the WDS AP is rebooted, manually or do to power outage, the WDS stations need to reboot in order to reconnect to the WDS AP. Keep Alive, allows this. Just type in the ip of the WDS AP, put in a time of 300 or 1000 s and click apply.

[edit] Not working as intended

Up to build r41189 as per this thread: https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1177905#top, it was found that in client mode, scheduled reboot does not work or more so, it only does it for the first time set, despite it being put as "every day." To fix this I used code which a moderator passed onto me and hopefully it works for you too.

  1. Go to DD-WRT configuration page
  2. Disable scheduled reboot in Administration -> Keep Alive
  3. Administration -> Commands
  4. Input
    echo "startservice run_rc_shutdown; /sbin/reboot" > /tmp/restart_router
     chmod a+x /tmp/restart_router
     echo "55 5 * * * root /tmp/restart_router" > /tmp/cron.d/restartrouter
  5. Save Startup
  6. You can edit this at any time
  7. I would also recommend giving your router a reboot just to be sure. Administration -> Management should be good enough

The above configuration will then restart every day at 5:55am assuming you have set the NTP correctly. You may also find it useful to find out more information on CRON

[edit] Alternative without the need of cron

  1. Go to DD-WRT configuration page
  2. Disable scheduled reboot in Administration -> Keep Alive
  3. Administration -> Commands
  4. Input
     >/tmp/reboot.sh
     echo 'current_year="1970"'>>/tmp/reboot.sh
     echo 'while [ $current_year -eq 1970 ]'>>/tmp/reboot.sh
     echo 'do'>>/tmp/reboot.sh
     echo '  sleep 60'>>/tmp/reboot.sh
     echo '  current_year=$(date +"%Y")'>>/tmp/reboot.sh
     echo 'done'>>/tmp/reboot.sh
     echo 'current_epoch=$(date +%s)'>>/tmp/reboot.sh
     echo 'target_epoch=$(date -d `date +"%Y%m%d0430"` +%s)'>>/tmp/reboot.sh
     echo 'sleep_seconds=$(( $target_epoch - $current_epoch ))'>>/tmp/reboot.sh
     echo 'if [[ ${sleep_seconds:0:1} == "-" ]] ; then sleep_seconds=$(( $sleep_seconds + 86400 )); fi'>>/tmp/reboot.sh
     echo 'sleep $sleep_seconds'>>/tmp/reboot.sh
     echo 'reboot'>>/tmp/reboot.sh
     echo '/bin/sh /tmp/reboot.sh &'>/tmp/reboot0.sh
     /bin/sh /tmp/reboot0.sh
  5. Save Startup
  6. You can edit this at any time
  7. Now reboot the router. It will from now on reboot every day at 4.30 am