Reboot via cron...

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> General Questions
Author Message
MoreBloodWine
DD-WRT User


Joined: 23 Jun 2016
Posts: 104

PostPosted: Wed Sep 11, 2019 2:21    Post subject: Reboot via cron... Reply with quote
I have the structure I'd like to use. One that's not offered via the one tab hence me looking at a cron job.

That being said... can I simply use (reboot) in a cron. Or is there a little more to it than that ?

_________________
Sponsor
bushant
DD-WRT Guru


Joined: 18 Nov 2015
Posts: 1136
Location: Indiana

PostPosted: Wed Sep 11, 2019 12:36    Post subject: Reply with quote
https://wiki.dd-wrt.com/wiki/index.php/Scheduled_reboot

I used this, a little different. Save as startup.

Code:
#echo "#!/bin/sh" > /tmp/restart_router
#echo "startservice run_rc_shutdown; /sbin/reboot" >> /tmp/restart_router
#chmod a+x /tmp/restart_router
#echo "19 3 */2 * * root /tmp/restart_router" > /tmp/cron.d/restartrouter

_________________
SUPPORTED DEVICES -- DON'T USE ROUTER DATABASE!
--IMPORTANT UPGRADE INFORMATION--Stubby DoT
Qualcomm-Atheros:
R7800 x2 kongat & BS WDS AP & Sta- R7500V2 kongat WDS STA- WNDR3700v4 BS std WDS STA- Nanostation M2 AirOS- LocoM2 AirOS
Broadcom:
R6200v2 kongac WLAN Repeater Archer C9 v1 OEM WAP
MoreBloodWine
DD-WRT User


Joined: 23 Jun 2016
Posts: 104

PostPosted: Wed Sep 11, 2019 12:46    Post subject: Reply with quote
bushant wrote:
https://wiki.dd-wrt.com/wiki/index.php/Scheduled_reboot

I used this, a little different. Save as startup.

Code:
#echo "#!/bin/sh" > /tmp/restart_router
#echo "startservice run_rc_shutdown; /sbin/reboot" >> /tmp/restart_router
#chmod a+x /tmp/restart_router
#echo "19 3 */2 * * root /tmp/restart_router" > /tmp/cron.d/restartrouter
saw that prior to me posting and still posted.

Not looking to do it that way.

_________________
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 61

PostPosted: Wed Sep 11, 2019 13:53    Post subject: Reply with quote
Well the answer already given says: yes you can call reboot from a cron job but you should run the administration shutdown commands first. Anything else your reboot script does in your "structure" is up to you.
MoreBloodWine
DD-WRT User


Joined: 23 Jun 2016
Posts: 104

PostPosted: Wed Sep 11, 2019 14:03    Post subject: Reply with quote
yoyoma2 wrote:
Well the answer already given says: yes you can call reboot from a cron job but you should run the administration shutdown commands first. Anything else your reboot script does in your "structure" is up to you.
so when I hit the reboot button, what commands are internally run because it's not a script put on hold at startup or the previously posted wouldnt be a suggestion.
_________________
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 61

PostPosted: Wed Sep 11, 2019 14:23    Post subject: Reply with quote
That's a question I'd like answered too: What happens when we click on "Reboot Router"?

Are the shutdown commands run?
Are mounted filesystems synced (usb, samba, jffs...)?
Are mounted filesystems unmounted?
MoreBloodWine
DD-WRT User


Joined: 23 Jun 2016
Posts: 104

PostPosted: Wed Sep 11, 2019 21:18    Post subject: Reply with quote
yoyoma2 wrote:
That's a question I'd like answered too: What happens when we click on "Reboot Router"?

Are the shutdown commands run?
Are mounted filesystems synced (usb, samba, jffs...)?
Are mounted filesystems unmounted?
exactly, whatever singular file is hit / command run when that reboot button is pushed, it may tie into other things, but that's all I need to hit with my Cron.
_________________
d0ug
DD-WRT Guru


Joined: 31 Jul 2015
Posts: 758

PostPosted: Thu Sep 12, 2019 5:29    Post subject: Reply with quote
If i had to make a guess the reboot command (/sbin/reboot) that the reboot button is calling. AFAIK this is not a standard command in most linux distros. You would usually reboot doing something like (shutdown -r now) I am not sure how cleanly this reboots the router. If you have one modded that you can attach a serial console to the router and then issue the reboot command you should be able to see what it is doing at the serial console. ie, if it is just hard resetting the CPU, or if it is cleanly shutting down and rebooting. You should be able to tell by what output is at the serial console after the command is run.

Technically there is no need to cleanly shutdown these things when they are used with no external storage installed. The persistent file system is all in read only flash and the writable space in /tmp is a RAM disk that gets nuked and recreated every time the router is rebooted anyways.
MoreBloodWine
DD-WRT User


Joined: 23 Jun 2016
Posts: 104

PostPosted: Thu Sep 12, 2019 17:14    Post subject: Reply with quote
d0ug wrote:
If i had to make a guess the reboot command (/sbin/reboot) that the reboot button is calling. AFAIK this is not a standard command in most linux distros. You would usually reboot doing something like (shutdown -r now) I am not sure how cleanly this reboots the router. If you have one modded that you can attach a serial console to the router and then issue the reboot command you should be able to see what it is doing at the serial console. ie, if it is just hard resetting the CPU, or if it is cleanly shutting down and rebooting. You should be able to tell by what output is at the serial console after the command is run.

Technically there is no need to cleanly shutdown these things when they are used with no external storage installed. The persistent file system is all in read only flash and the writable space in /tmp is a RAM disk that gets nuked and recreated every time the router is rebooted anyways.
well, just to play Devil's Advocate then.

Let's say that the reboot button doesn't cleanly shut it down. Then wouldn't that technically be a coding erro on the devs side of things considering the previously posted code is off the DD wrt Wiki? LOL

If someone does know how to dig into the routers coude... could you share what command that reboot button calls ?

FWIW... this is what I'm running not thst I think it matters.

Firmware: DD-WRT v3.0-r37495M kongat (10/28/1Cool

But ya. Clean or otherwise, if it doesnt matter based on the last reply. I probably could go with a simple reboot since my only attached storage is a mini 64gb USB used for Yamon.

_________________
MoreBloodWine
DD-WRT User


Joined: 23 Jun 2016
Posts: 104

PostPosted: Thu Sep 12, 2019 17:19    Post subject: Reply with quote
In addition to mt previous reply. Then in theory this should work in the cron section under management, right ?

0 6 1,15 * * /sbin/reboot

Right? Or am I missing a period and or slash somewhere ?

_________________
MoreBloodWine
DD-WRT User


Joined: 23 Jun 2016
Posts: 104

PostPosted: Sat Sep 14, 2019 3:12    Post subject: Reply with quote
MoreBloodWine wrote:
In addition to mt previous reply. Then in theory this should work in the cron section under management, right ?

0 6 1,15 * * /sbin/reboot

Right? Or am I missing a period and or slash somewhere ?
Odly enough 15th falls on a sunday this week. So will post back after testing the above, but even if it is a "hard"reset.

With no external storage other than a USB mini thumb for Yamon, this will just be a "controlled power outage" which has never seemed to affect the router in any way. Since I've been using DDWRT, I've experienced maybe 8 power outages. 2-3 of which were come and goes in matter of seconds if that makes sense, and the router still seems GTG.

But I will know if the command works if my uptime changes. Which right now stands at 23 days.

_________________
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum