Posted: Wed Nov 02, 2022 1:57 Post subject: Scheduled reboot using Cron not working.
Hi DD-WRT team.
Thanks a lot for hard work on the DD-WRT firmware.
I tried looking for a solution to reboot the router using Cron on the TP-Link TL-WDR4300. I am on DD-WRT v3.0-r50500 std (10/13/22). Scheduled reboot under 'Keep Alive' works as expected. However, I was experimenting with restarting the router twice a week using Cron, instead of restarting everyday. I followed the instructions at https://wiki.dd-wrt.com/wiki/index.php/Scheduled_reboot
Steps I followed are:
1. Disabled 'Scheduled Reboot' under Administration -> Keep Alive
2. Enabled Cron under Administration -> Management.
3. Pasted the following code in the 'Additional jobs' textbox:
4. I want to restart the router at 3 AM every Tuesday and Friday.
5. I saved and applied settings. Even rebooted the router.
6. I do see the 'cron' process running when I run the 'top' command in telnet.
The router does not restart, nor do I see any attempt to reboot the router in syslog.
Tried this on another router, TP-Link TL-WDR3500, with same results. I tried searching the forums for similar issue, but did not find any topics.
What am I missing?
Regards,
-Pranav.
Last edited by cyberpranav on Tue Nov 15, 2022 23:08; edited 2 times in total
"Additional cron jobs" are entered as a crontab, not a script; the reference clearly states to put that in Administration -> Commands and save as startup.
Joined: 31 Jul 2021 Posts: 2146 Location: All over YOUR webs
Posted: Wed Nov 02, 2022 10:38 Post subject:
Ive suggested a web interface enhancement to support everyday/single day/multiple days like we already do in access restrictions. Would be far more useful/flexible imo.
Posted: Wed Nov 02, 2022 20:40 Post subject: This would be awesome!
the-joker wrote:
Ive suggested a web interface enhancement to support everyday/single day/multiple days like we already do in access restrictions. Would be far more useful/flexible imo.
Posted: Tue Nov 15, 2022 23:06 Post subject: Router does not reboot.
Hi team.
Seems like I am making some other mistake which is preventing the router from rebooting. Attached is how the current startup code looks like. I tried changing the job to restart everyday, instead of Tuesday and Friday, but still does not work.
Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Wed Nov 16, 2022 12:21 Post subject: Re: Router does not reboot.
cyberpranav wrote:
1. Disabled 'Scheduled Reboot' under Administration -> Keep Alive
2. Enabled Cron under Administration -> Management.
3. Pasted the following code in the 'Additional jobs' textbox:
4. I want to restart the router at 3 AM every Tuesday and Friday.
5. I saved and applied settings. Even rebooted the router.
6. I do see the 'cron' process running when I run the 'top' command in telnet.
The router does not restart, nor do I see any attempt to reboot the router in syslog.
cyberpranav wrote:
Hi team.
Seems like I am making some other mistake which is preventing the router from rebooting. Attached is how the current startup code looks like. I tried changing the job to restart everyday, instead of Tuesday and Friday, but still does not work.
You sure that Cron is running? Run `ps | grep -i cron` to check.
Also, test run your /tmp/restart_router in a shell to make sure that it has no error.
You don't have to use "chmod a+x", just call it by "/bin/sh restart_router" in the cron entry!
But if you insist, make sure that the first line of restart_router is "#!/bin/sh"!
BTW, you can use the logger command to write an entry into /var/log/messages!
Code:
/usr/bin/logger "restart_router[$$]: started"
I remember some differences between system cron entry (/etc/crontab) and user ones... might not be relevant. But DD-WRT is not a standard Linux distribution.
Posted: Thu Nov 17, 2022 22:09 Post subject: Re: Router does not reboot.
mwchang wrote:
cyberpranav wrote:
1. Disabled 'Scheduled Reboot' under Administration -> Keep Alive
2. Enabled Cron under Administration -> Management.
3. Pasted the following code in the 'Additional jobs' textbox:
4. I want to restart the router at 3 AM every Tuesday and Friday.
5. I saved and applied settings. Even rebooted the router.
6. I do see the 'cron' process running when I run the 'top' command in telnet.
The router does not restart, nor do I see any attempt to reboot the router in syslog.
cyberpranav wrote:
Hi team.
Seems like I am making some other mistake which is preventing the router from rebooting. Attached is how the current startup code looks like. I tried changing the job to restart everyday, instead of Tuesday and Friday, but still does not work.
You sure that Cron is running? Run `ps | grep -i cron` to check.
Also, test run your /tmp/restart_router in a shell to make sure that it has no error.
You don't have to use "chmod a+x", just call it by "/bin/sh restart_router" in the cron entry!
But if you insist, make sure that the first line of restart_router is "#!/bin/sh"!
BTW, you can use the logger command to write an entry into /var/log/messages!
Code:
/usr/bin/logger "restart_router[$$]: started"
I remember some differences between system cron entry (/etc/crontab) and user ones... might not be relevant. But DD-WRT is not a standard Linux distribution.
Posted: Tue Nov 22, 2022 2:54 Post subject: Re: Scheduled reboot using Cron not working.
cyberpranav wrote:
Scheduled reboot under 'Keep Alive' works as expected. However, I was experimenting with restarting the router twice a week using Cron, instead of restarting everyday.
Since 'Keep Alive' works as expected you know cron is working. Just pick Tuesday in the GUI instead of Everyday (Save & Apply) and you're half way there. You can see the cron job dd-wrt created with:
Code:
cat /tmp/cron.d/check_schedules
Then in a startup command, echo the output of the above command to a different file like (check_schedules2) but change the 02 to 05 and you have your Friday reboots.
Another solution would be to set the nvram variable schedule_weekdays to 02,05 at the command-line. The GUI doesn't allow selecting multiple days but the underlying code seems to support it. The problem is, any later saving of 'Keep Alive' in the GUI will overwrite schedule_weekdays losing your two day hack.
Or put this in the "Additional Cron Jobs" input textbox and save after removing the third line from the startup script:
Code:
0 3 * * 2,5 root /tmp/restart_router
Which is what I was suggesting in the first place. _________________ "The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep." - Robert Frost
"I am one of the noticeable ones - notice me" - Dale Frances McKenzie Bozzio
The point is that generating restart_router is useless. If he wants to disable dd-wrt's Keep Alive->Schedule Reboot completely, then sure this additional cron job alone can do the trick instead of solutions given earlier (same difference).
Correct, I was refraining from stating the obvious because people get a little offended by that. _________________ "The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep." - Robert Frost
"I am one of the noticeable ones - notice me" - Dale Frances McKenzie Bozzio