Daily cron reboots

Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware
Author Message
beamer7296
DD-WRT Novice


Joined: 08 Jun 2010
Posts: 24

PostPosted: Sun Jun 23, 2013 20:27    Post subject: Daily cron reboots Reply with quote
I've read about the known issues with the reboot scheduler in v24 via Administration > Keep Alive so I've been trying to get the reboots to occur via my own cron job. There are a number of posts which suggest using the below commands on startup via Administration > Commands. I modified the command to run every 5 minutes while I test to verify that it's functioning as intended.

Code:
echo "startservice run_rc_shutdown; /sbin/reboot" > /tmp/restart_router
chmod a+x /tmp/restart_router
echo "*/5 * * * * root /tmp/restart_router" > /tmp/cron.d/restartrouter


However, I haven't actually been able to get this to work. I verified that the /tmp/restart_router and /tmp/cron.d/restartrouter files are all created with the correct permissions at startup, but the reboot never actually occurs.

Here's the files and their permissions:
    -rwxr-xr-x /tmp/restart_router
    -rw-r--r-- /tmp/cron.d/restartrouter


I also fiddled around with the Additional Cron Jobs via Administration > Management. I was able to get the reboot to occur once with this method, but not on a recurring basis which is similar to the known defect in the Keep Alive reboot scheduler (I'm not sure if the root cause is identical for the two issues).

I've tried modifying the script, investigating the PATH environment variables, verifying cron is enabled/running, and experimenting with different cron functionality within dd-wrt to no avail. Any thoughts on what the issue might be and how I can go about troubleshooting this further?

Firmware version: DD-WRT v24-sp2 (04/15/13) std - build 21286
Sponsor
checho
DD-WRT Guru


Joined: 27 Feb 2007
Posts: 527
Location: Bulgaria

PostPosted: Mon Jun 24, 2013 4:54    Post subject: Reply with quote
This is because you have omitted '#/bin/sh' in the beginning of the script. Try to add it to your script as a first line and everything must be okay. This is a known issue that deals with shell scripts on dd-wrt in the last year.
beamer7296
DD-WRT Novice


Joined: 08 Jun 2010
Posts: 24

PostPosted: Sat Jul 06, 2013 23:26    Post subject: Reply with quote
Looks like that did the trick, thank you very much for your help!

Here's the script in case others have the same difficulty:
Code:
echo "#!/bin/sh" > /tmp/restart_router
echo "startservice run_rc_shutdown; /sbin/reboot" >> /tmp/restart_router
chmod a+x /tmp/restart_router
echo "15 3 * * * root /tmp/restart_router" > /tmp/cron.d/restartrouter
beamer7296
DD-WRT Novice


Joined: 08 Jun 2010
Posts: 24

PostPosted: Sun Jul 07, 2013 20:59    Post subject: Reply with quote
I may have spoken a bit prematurely. This appears to be working on my WDS AP, but not on my WDS Station device. Both are identical physicals devices with the same firmware version. I remember reading about someone else having the same issue, but I can't seem to find the post again. Any ideas?
beamer7296
DD-WRT Novice


Joined: 08 Jun 2010
Posts: 24

PostPosted: Mon Jul 22, 2013 14:49    Post subject: Reply with quote
Any additional thoughts from the community on why this isn't working on my WDS Station, but is working on my WDS AP?
beamer7296
DD-WRT Novice


Joined: 08 Jun 2010
Posts: 24

PostPosted: Tue Aug 06, 2013 2:16    Post subject: Reply with quote
I've been doing some tinkering to try to get this work and trying to get creative, but I've run out of ideas. Anyone have any ideas besides walking my lazy behind the TV to reset the router on a regular basis?
les_garten
DD-WRT Novice


Joined: 24 Feb 2011
Posts: 2

PostPosted: Fri May 06, 2016 2:25    Post subject: I got this to work, here's how Reply with quote
I know this is an old thread, but since I never found the answer anywhere that worked, and I just got this to work after playing with it a few days, I thought I would post my solution here.

The restart_router script entry in /tmp/restart_router indeed needs the shebang portion or it will not run.

The echo commands in post #3 won't echo both lines to the restart_router file

I discovered that the cron entry ran every time if I manually used vi to edit in the shebang into the restart_router entry.

so my solution is this:

1) enable JFFS in Administration per instructions on DD-WRT Wiki, FOLLOW IINSTRUCTIONS! OR BRICK Maybe
2) mkdir /jffs/etc
3) touch /jffs/etc/restart_router
4) chmod a+x /jffs/etc/restart_router
5) I used vi to edit /jffs/etc/restart_router to be this:
#!/bin/sh
startservice run_rc_shutdown; /sbin/reboot

6) Then here is my Administration >> Command >> for startup

cp /jffs/etc/restart_router /tmp/restart_router
echo "55 7 * * 6 root /tmp/restart_router" > /tmp/cron.d/restartrouter

This works!

Hope this helps
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Atheros WiSOC based Hardware 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 cannot attach files in this forum
You cannot download files in this forum