02-06-2014 11:42 PM - edited 03-07-2019 06:04 PM
Hello,
Is it possible to have a router schedule itself to reload every night or once a week?
We have some Cisco 3g wireless routers in remote locations and if we lose connectivity we have to get someone to power cycle the router to get the 3g working again.
I have added an SLA script to the router that pings Google and if it can't it will do a test on the cellular modem which will power cycle that part of the router only which may help.
With a local schedule reload on top of the SLA I'm sure it will be much more reliable. I have a schedule tool that can do remote reloads but if the router is down then we are stuck and home the SLA works.
Thanks
02-07-2014 04:20 AM
Andy,
You can do this with an eem script:
event manager applet ReloadRouter
event timer cron cron-entry "0 0 * * 0"
action 1.0 cli command wr
action 2.0 cli command reload
The above will reload at midnight on Sunday. The fields for 0 0 * * 0 are: minutes, hour, day of month, month, and day of week. Day of week starts on Sunday and is represented by 0 to 6 for Saturday. Time is 24 hour time.
You can also use macros like:
event timer cron cron-entry @weekly name Sunday
This should reload at midnight on Sunday.
HTH,
John
*** Please rate all useful posts ***
02-07-2014 04:38 AM
This sounds like just what I need. I need to restart daily at 5am, woud this be possible?
Also I already have an eem script on there reloading the internal cellular modem, but have no idea if it has been working:
track 234 ip sla 1 reachability
ip sla 1
icmp-echo 10.100.1.66 source-interface Vlan10
frequency 5
ip sla schedule 1 life forever start-time now
event manager applet test
event track 234 state down
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "service internal"
action 4.0 cli command "end"
action 5.0 cli command "test cellular 0 modem-power-cycle"
action 6.0 cli command "config t"
action 7.0 cli command "no service internal"
action 8.0 cli command "end" event manager applet test
02-07-2014 04:56 AM
You should be able to see when the event was triggered with "show event manager history events". If you have entries in there, it's a good chance that your other script has been working.
As far as 5am, absolutely:
event timer cron cron-entry "0 5 * * *"
That should do it.
HTH,
John
*** Please rate all useful posts ***
02-07-2014 05:56 AM
So the "*" mean daily?
Looks like the SLA eem script is also working thanks to your commands:
show event manager history events
No. Job Id Proc Status Time of Event Event Type Name
1 42 Actv success Fri Feb 7 00:48:07 2014 track applet: test
2 43 Actv success Fri Feb 7 00:48:22 2014 track applet: test
3 46 Actv success Fri Feb 7 08:08:58 2014 track applet: test
4 47 Actv success Fri Feb 7 08:09:13 2014 track applet: test
Thanks
02-07-2014 06:02 AM
Yes, the * means any. You could also do "0 5 * * 0-6" if that makes you feel more comfortable.
HTH,
John
*** Please rate all useful posts ***
02-07-2014 07:42 AM
Hello
Here is another example:
reload 16;45 on fridays
========================
"45 16 * * 5" = "min hour dayofmonth monthofyear dayofweek" (0 = sunday)
event manager applet reload
event timer cron cron-entry "45 16 * * 5"
action 1.0 syslog msg "Router 1 is about to reload"
action 1.1 cli command "enable"
action 1.2 cli command "wr"
action 1.3 reload
#sh event manager policy registered
No. Class Type Event Type Trap Time Registered Name
1 applet user timer cron Off Fri Feb 7 16:43:57 2014 reload
cron entry {45 16 * * 5}
maxrun 20.000
action 1.0 syslog msg "Router 1 is about to reload"
action 1.1 cli command "enable"
action 1.2 cli command "wr"
action 1.3 reload
res
Paul
Please don't forget to rate any posts that have been helpful.
Thanks.
02-07-2014 08:28 AM
Let me take a look guys, so I put the times in as a word?
Router#event timer cron cron-entry ?
WORD Cron entry string
Also is the asterix "*" just an ignore?
Thanks
02-07-2014 08:37 AM
Andy,
Basically * is an ignore or just simply put that you don't want a value in that particular field. The cron-entry should be surrounded by quotes as in my previous post.
HTH,
John
*** Please rate all useful posts ***
02-07-2014 08:47 AM
Thanks I'm going to test this on a live router as my test one worked, I will use
(config)#event manager applet ReloadRouter
(config-applet)#event timer cron cron-entry "0 5 * * *"
(config-applet)#action 1.0 cli command wr
(config-applet)#action 2.0 cli command reload
I will let you know how it goes!
Once again thanks
02-07-2014 09:16 AM
Hello John
Would that do it on a daily basis?
I thought something like this would be required-
event timer cron cron-entry "0 5 * * @weekly"
res
Paul
Please don't forget to rate any posts that have been helpful.
Thanks.
02-07-2014 09:27 AM
Paul,
It should. Cron will assume it's every day if there's not a value listed for the day of week field.
You can also use the variable if you want as well as "0-6" for the day, but it should work fine with just the '*'.
HTH,
John
*** Please rate all useful posts ***
02-07-2014 09:41 AM
Another option that you may have is using regular kron to do this as well:
kron policy-list ReloadRouter
cli wr
cli reload
kron occurrence DailyReload at 05:00 recurring
policy-list ReloadRouter
R1#sh kron schedule
Kron Occurrence Schedule
DailyReload inactive, will run again in 0 days 17:24:38 at 5 :00 on
The 17:24:38 is how many minutes it takes before the next run. So in my example, it's almost 17.5 hours away from 5am.
For what you're wanting to do, this may be easier than running more eem applets.
HTH,
John
*** Please rate all useful posts ***
02-07-2014 10:47 AM
I will try both as I am now intrigued
I've just got home and tried both in GNS3 and the commands worked, but nothing happed at the set time I put in. I guess it could be a limitation of GNS3, I don't have a router at home, so I have to wait to Monday.
eem scripts are somehting I need to really get into, my CCNP didn't really touch on them, must be taught somewhere else.
02-07-2014 11:38 AM
Yeah, GNS doesn't reload routers like you would see on a real router. It just stares at you
HTH,
John
*** Please rate all useful posts ***
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide