Dd Wrt Cron Reboot

cron and reboot or apply settings

DD-WRT Forum Forum Index ->Advanced Networking

If you want to restart your DD-WRT router every night for whatever. Echo '45 23. Faizal hijjaz. root /tmp/restartrouter' /tmp/cron.d /restartrouter.

View previous topic :: View next topic
AuthorMessage
nick_woodforth
DD-WRT Novice
Joined: 19 Mar 2015
Posts: 4

Posted: Thu Mar 19, 2015 14:03 Post subject: cron and reboot or apply settings
hey all,
im using TP-Link TL-WR740N v4 router.
my goal that im trying to get to is i want my wireless to change its MAC and SSID every few mins for use with streetpass(Nintendo ds or so now as homepass)
im trying to do this with using only cron. so far i have found a code that will change the MAC and SSID but will not apply the settings or reboot
Code:
0 0,3,6,9,12,15,18,21 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:40 sleep 3 && nvram set wl_ssid='NZ@McD1' sleep 3 && nvram set wl0_ssid='NZ@McD1' sleep 3 && nvram commit sleep
9 0,3,6,9,12,15,18,21 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:41 sleep 3 && nvram set wl_ssid='NZ@McD2' sleep 3 && nvram set wl0_ssid='NZ@McD2' sleep 3 && nvram commit sleep 5
18 0,3,6,9,12,15,18,21 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:42 sleep 3 && nvram set wl_ssid='NZ@McD1' sleep 3 && nvram set wl0_ssid='NZ@McD1' sleep 3 && nvram commit sleep 5
27 0,3,6,9,12,15,18,21 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:43 sleep 3 && nvram set wl_ssid='NZ@McD2' sleep 3 && nvram set wl0_ssid='NZ@McD2' sleep 3 && nvram commit sleep 5
36 0,3,6,9,12,15,18,21 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:44 sleep 3 && nvram set wl_ssid='NZ@McD1' sleep 3 && nvram set wl0_ssid='NZ@McD1' sleep 3 && nvram commit sleep 5
45 0,3,6,9,12,15,18,21 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:45 sleep 3 && nvram set wl_ssid='NZ@McD2' sleep 3 && nvram set wl0_ssid='NZ@McD2' sleep 3 && nvram commit sleep 5
54 0,3,6,9,12,15,18,21 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:46 sleep 3 && nvram set wl_ssid='NZ@McD1' sleep 3 && nvram set wl0_ssid='NZ@McD1' sleep 3 && nvram commit sleep 5
3 1,4,7,10,13,16,19,22 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:47 sleep 3 && nvram set wl_ssid='NZ@McD2' sleep 3 && nvram set wl0_ssid='NZ@McD2' sleep 3 && nvram commit sleep 5
12 1,4,7,10,13,16,19,22 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:48 sleep 3 && nvram set wl_ssid='NZ@McD1' sleep 3 && nvram set wl0_ssid='NZ@McD1' sleep 3 && nvram commit sleep 5
21 1,4,7,10,13,16,19,22 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:49 sleep 3 && nvram set wl_ssid='NZ@McD2' sleep 3 && nvram set wl0_ssid='NZ@McD2' sleep 3 && nvram commit sleep 5
30 1,4,7,10,13,16,19,22 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:4A sleep 3 && nvram set wl_ssid='NZ@McD1' sleep 3 && nvram set wl0_ssid='NZ@McD1' sleep 3 && nvram commit sleep 5
39 1,4,7,10,13,16,19,22 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:4B sleep 3 && nvram set wl_ssid='NZ@McD2' sleep 3 && nvram set wl0_ssid='NZ@McD2' sleep 3 && nvram commit sleep 5
48 1,4,7,10,13,16,19,22 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:4C sleep 3 && nvram set wl_ssid='NZ@McD1' sleep 3 && nvram set wl0_ssid='NZ@McD1' sleep 3 && nvram commit sleep 5
57 1,4,7,10,13,16,19,22 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:4D sleep 3 && nvram set wl_ssid='NZ@McD2' sleep 3 && nvram set wl0_ssid='NZ@McD2' sleep 3 && nvram commit sleep 5
6 2,5,8,11,14,17,20,23 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:4E sleep 3 && nvram set wl_ssid='NZ@McD1' sleep 3 && nvram set wl0_ssid='NZ@McD1' sleep 3 && nvram commit sleep 5
15 2,5,8,11,14,17,20,23 * * * root nvram set def_whwaddr=4E:53:50:4F:4F:4F sleep 3 && nvram set wl_ssid='NZ@McD2' sleep 3 && nvram set wl0_ssid='NZ@McD2' sleep 3 && nvram commit sleep 5
24 2,5,8,11,14,17,20,23 * * * root nvram set def_whwaddr=00:25:9C:52:1C:6A sleep 3 && nvram set wl_ssid='NZ@McD1' sleep 3 && nvram set wl0_ssid='NZ@McD1' sleep 3 && nvram commit sleep 5
33 2,5,8,11,14,17,20,23 * * * root nvram set def_whwaddr=00:0D:67:15:2D:82 sleep 3 && nvram set wl_ssid='NZ@McD2' sleep 3 && nvram set wl0_ssid='NZ@McD2' sleep 3 && nvram commit sleep 5
42 2,5,8,11,14,17,20,23 * * * root nvram set def_whwaddr=00:0D:67:15:D7:21 sleep 3 && nvram set wl_ssid='NZ@McD1' sleep 3 && nvram set wl0_ssid='NZ@McD1' sleep 3 && nvram commit sleep 5
51 2,5,8,11,14,17,20,23 * * * root nvram set def_whwaddr=00:0D:67:15:D5:44 sleep 3 && nvram set wl_ssid='NZ@McD2' sleep 3 && nvram set wl0_ssid='NZ@McD2' sleep 3 && nvram commit sleep 5

the code when i found it had '&& reboot' at the end of the lines but it wouldnt work for me so i removed them.
so at the moment i have been hitting apply settings and its working but i would like cron to do it so i dont have to worry about hitting apply settings every 9 min and spend more time having fun
any help would be great and thanks in advance[/quote]
Sponsor
<=' td='>
nick_woodforth
DD-WRT Novice
Joined: 19 Mar 2015
Posts: 4

Posted: Thu Mar 19, 2015 15:43 Post subject:
Quote:
eibgrad
PostPosted: Fri Mar 20, 2015 0:42 Post subject:
I don’t know who wrote the original script, but whoever it was did a pretty bad job. All I see are numerous syntax errors (e.g., not putting semi-colons between commands), and too much reliance on && (that can lead to unexpected results if you’re not careful).
A few months back I helped someone w/ a very similar problem, and presumably using the same script as the basis for their own script. I provided a properly coded script, but they never responded as to whether it worked for them (worked for me). The script I provided is the PROPER way to build a series of commands to be executed by cron.
http://www.dd-wrt.com/phpBB2/viewtopic.php?p=938367[/code]

thanks eidgrad
unfortunately thats worse for me now the MAC or SSID are not changing. but i could have edited the code wrong
Code:
script='/tmp/myscript.sh'
cat << 'EOF' > $script
#!/bin/sh
sleep 60
cat << 'EOF2' >> '/tmp/crontab'
0 0,3,6,9,12,15,18,21 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:40; nvram set wl_ssid='NZ@McD1'; nvram set wl0_ssid='NZ@McD1'; nvram commit; reboot'
9 0,3,6,9,12,15,18,21 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:41; nvram set wl_ssid='NZ@McD2'; nvram set wl0_ssid='NZ@McD2'; nvram commit; reboot&#-110;
18 0,3,6,9,12,15,18,21 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:42; nvram set wl_ssid='NZ@McD1'; nvram set wl0_ssid='NZ@McD1'; nvram commit; reboot&#-110;
27 0,3,6,9,12,15,18,21 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:43; nvram set wl_ssid='NZ@McD2'; nvram set wl0_ssid='NZ@McD2'; nvram commit; reboot&#-110;
36 0,3,6,9,12,15,18,21 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:44; nvram set wl_ssid='NZ@McD1'; nvram set wl0_ssid='NZ@McD1'; nvram commit; reboot&#-110;
45 0,3,6,9,12,15,18,21 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:45; nvram set wl_ssid='NZ@McD2'; nvram set wl0_ssid='NZ@McD2'; nvram commit; reboot&#-110;
54 0,3,6,9,12,15,18,21 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:46; nvram set wl_ssid='NZ@McD1'; nvram set wl0_ssid='NZ@McD1'; nvram commit; reboot&#-110;
3 1,4,7,10,13,16,19,22 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:47; nvram set wl_ssid='NZ@McD2'; nvram set wl0_ssid='NZ@McD2'; nvram commit; reboot&#-110;
12 1,4,7,10,13,16,19,22 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:48; nvram set wl_ssid='NZ@McD1'; nvram set wl0_ssid='NZ@McD1'; nvram commit; reboot&#-110;
21 1,4,7,10,13,16,19,22 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:49; nvram set wl_ssid='NZ@McD2'; nvram set wl0_ssid='NZ@McD2'; nvram commit; reboot&#-110;
30 1,4,7,10,13,16,19,22 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:4A; nvram set wl_ssid='NZ@McD1'; nvram set wl0_ssid='NZ@McD1'; nvram commit; reboot&#-110;
39 1,4,7,10,13,16,19,22 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:4B; nvram set wl_ssid='NZ@McD2'; nvram set wl0_ssid='NZ@McD2'; nvram commit; reboot&#-110;
48 1,4,7,10,13,16,19,22 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:4C; nvram set wl_ssid='NZ@McD1'; nvram set wl0_ssid='NZ@McD1'; nvram commit; reboot&#-110;
57 1,4,7,10,13,16,19,22 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:4D; nvram set wl_ssid='NZ@McD2'; nvram set wl0_ssid='NZ@McD2'; nvram commit; reboot&#-110;
6 2,5,8,11,14,17,20,23 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:4E; nvram set wl_ssid='NZ@McD1'; nvram set wl0_ssid='NZ@McD1'; nvram commit; reboot&#-110;
15 2,5,8,11,14,17,20,23 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr=4E:53:50:4F:4F:4F; nvram set wl_ssid='NZ@McD2'; nvram set wl0_ssid='NZ@McD2'; nvram commit; reboot&#-110;
24 2,5,8,11,14,17,20,23 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr= 00:25:9C:52:1C:6A; nvram set wl_ssid='NZ@McD1'; nvram set wl0_ssid='NZ@McD1'; nvram commit; reboot&#-110;
33 2,5,8,11,14,17,20,23 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr= 00:0D:67:15:2D:82; nvram set wl_ssid='NZ@McD2'; nvram set wl0_ssid='NZ@McD2'; nvram commit; reboot&#-110;
42 2,5,8,11,14,17,20,23 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr= 00:0D:67:15:D7:21; nvram set wl_ssid='NZ@McD1'; nvram set wl0_ssid='NZ@McD1'; nvram commit; reboot&#-110;
51 2,5,8,11,14,17,20,23 * * * root/bin/sh &#-106;c &#-111;nvram set def_whwaddr= 00:0D:67:15:D5:44; nvram set wl_ssid='NZ@McD2'; nvram set wl0_ssid='NZ@McD2'; nvram commit; reboot&#-110;
EOF2
stopservice cron
sleep 3
startservice cron
EOF
chmod +x $script
$script &

but i did notice that the time on the dd wrt was at 00:15:02 up 15 min so im thinking every time i reboot the router its going back to 00:00:00
is there anyway of a apply settings instead of reboot? then i wouldnt have to worry about the time??
EDIT: just noticed that when copying and pasting some of the code changed. have to get some sleep now so will try and fix it in the morning or next time i have a few mins to go though it again
nick_woodforth
DD-WRT Novice
Joined: 19 Mar 2015
Posts: 4

Posted: Mon Mar 23, 2015 9:35 Post subject:
hey eibgrad
the code u said to use isnt working.
its not changing macs or ssid's and its not rebooting ether.
when i reboot it manualy it resets the clock and i dont no what the couse of that is ether. i have tryed to set the ntp sever but i dont no y its not working but its not.
any help would be good.
is there a way to say to cron to apply settings instead of rebooting?
eibgrad
DD-WRT Guru
Joined: 18 Sep 2010
Posts: 8033

Posted: Mon Mar 23, 2015 14:59 Post subject:
What's w/ all this stuff in the code?
&#-106;
&#-111;
&#-110;
Looks to me like you processed this through some kind of html tool. Or at least the editor thought it was html. That's html markup code for handling special chars.
http://www.ascii.cl/htmlcodes.htm
IOW, you messed up the script.
nick_woodforth
DD-WRT Novice
Joined: 19 Mar 2015
Posts: 4

Posted: Mon Mar 23, 2015 22:47 Post subject:
Quote:
eibgrad
PostPosted: Tue Mar 24, 2015 0:59 Post subject:
What's w/ all this stuff in the code?
&#-106;
&#-111;
&#-110;
Looks to me like you processed this through some kind of html tool. Or at least the editor thought it was html. That's html markup code for handling special chars.

hey eibgrad
when i edited it i was using notepad but sometimes my computer opened it in microsoft word and it had changed some of the cod to special chars. so when i copyed and pasted the code into cron and hit apply it changed to the &#-106; = - , &#-111; = ' , &#-110; = '
i did fix all of this before i posted last night but it didnt work for me
eibgrad
DD-WRT Guru
Joined: 18 Sep 2010
Posts: 8033

Posted: Tue Mar 24, 2015 18:40 Post subject:
Well there are others errors as well. root/bin/sh is not correct. It's root /bin/sh (a space between root and /bin/sh).
DD-WRT Forum Forum Index ->Advanced NetworkingAll times are GMT

NavigationDd wrt model

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

Related Post