EEM script scheduling? Can I run a script at a certain time?

Answered Question
Nov 10th, 2008

I currently have an EEM script running that sends me the output of "show interface" every 24 hours (aka 86400 seconds) via the following:

event manager environment _mail_domain dzubin.com

event manager environment _mail_smtp emailserver

event manager environment _mail_rcpt [email protected]

event manager applet everyday

event timer watchdog time 86400 maxrun 9999999

action 1.0 info type routername

action 1.5 cli command "enable"

action 2.0 cli command "show int FastEthernet4"

action 3.0 mail server "$_mail_smtp" to "$_mail_rcpt" from "$_info_routername@$_mail_domain" subject "show interface FastEthernet4" body "$_cli_result"

It works great, but the timing gets all screwed up if the router is rebooted. I have NTP enabled on the router... is there any was to schedule the script to run at a certain time rather than just after 86400 seconds?

I have this problem too.
0 votes
Correct Answer by Joe Clarke about 8 years 1 month ago

Sure, just convert the watchdog timer to a cron timer:

event timer cron cron-entry "0 0 * * *" maxrun 9999999

This will run the policy at midnight.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (1 ratings)
Loading.
Correct Answer
Joe Clarke Mon, 11/10/2008 - 08:48

Sure, just convert the watchdog timer to a cron timer:

event timer cron cron-entry "0 0 * * *" maxrun 9999999

This will run the policy at midnight.

thomasdzubin Tue, 11/11/2008 - 09:16

Although, oddly enough, now that I've switched my applet to run with a cron timer, it now runs TWICE at the appropriate time....so I end up getting two emails. Very strange...might be an IOS bug...I'll upgrade.

Joe Clarke Tue, 11/11/2008 - 09:23

I haven't seen this before. Only one policy of a given name can run at a given time. What version of IOS is this? What is the output of "show event manager history events"?

thomasdzubin Tue, 11/11/2008 - 14:04

Running Cisco IOS Software, C870 Software (C870-ADVIPSERVICESK9-M), Version 12.4(15)T4, RELEASE SOFTWARE (fc2)

My applet starts with:

event manager applet testemailapplet

event timer cron name "_EEMinternalname3" cron-entry "52 14 * * *" maxrun 9999999

MyRouter#show event manager history events

No. Time of Event Event Type Name

1 Tue Nov11 14:46:12 2008 timer watchdog applet: everyminute

2 Tue Nov11 14:47:12 2008 timer watchdog applet: everyhour

3 Tue Nov11 14:47:12 2008 timer watchdog applet: everyminute

4 Tue Nov11 14:48:12 2008 timer watchdog applet: everyminute

5 Tue Nov11 14:49:12 2008 timer watchdog applet: everyminute

6 Tue Nov11 14:50:12 2008 timer watchdog applet: everyminute

7 Tue Nov11 14:51:12 2008 timer watchdog applet: everyminute

8 Tue Nov11 14:52:00 2008 timer cron applet: testemailapplet

9 Tue Nov11 14:52:12 2008 timer watchdog applet: everyminute

10 Tue Nov11 14:52:59 2008 timer cron applet: testemailapplet

MyRouter#

Joe Clarke Tue, 11/11/2008 - 16:52

It looks more like testemailapplet ran at 14:52 followed by everyminute at 14:52:12. Perhaps that is why you saw two emails.

thomasdzubin Tue, 11/11/2008 - 20:34

No, "everyminute" is just a mostly-empty applet that I was just playing around with:

event manager applet everyminute

event timer watchdog time 60 maxrun 4294967295

action 1.0 counter name "foo" op inc value 1

From my read of the event manager history, "testemailapplet" seems to run at the 0-th second of the minute AND the 59-th second of the minute.

very odd... looks like a bug to me.

Joe Clarke Tue, 11/11/2008 - 21:10

I saw that, but based on your description, it sounded as if the policies were running much closer together. Please post the output of "show event manager policy registered". You may be running into an unexpected feature of the cron timer.

Joe Clarke Tue, 11/11/2008 - 22:34

FYI, I have since upgraded my main EEM test router to 12.4(22)T, and I cannot reproduce there with your testemailapplet configured. The applet always runs once at the 0th second. It did not run at the 59th second:

3 41509 Actv success Wed Nov12 01:29:00 2008 timer cron applet: testemailapplet

4 41510 Actv success Wed Nov12 01:29:06 2008 timer watchdog script: qos_pol.tcl

5 41511 Actv success Wed Nov12 01:29:49 2008 timer watchdog applet: Countdown

6 41512 Actv success Wed Nov12 01:30:06 2008 timer watchdog script: qos_pol.tcl

I still think what you're seeing may actually be expected based on your overall EEM config, but if there was a bug, it appears to be fixed in 12.4(22)T.

thomasdzubin Wed, 11/12/2008 - 10:21

Although I like troubleshooting as much as the next guy... I decided to do the "Microsoft" thing and rebooted the router. double-email problem fixed...

Thanks for the help

Florin Barhala Sat, 12/15/2012 - 09:16

Hi mate,

I am trying to run a script every 3h using cron. Couldn't do it so I started from scratch with a simple one:

event manager applet Test-3h

event timer cron name Test cron-entry "* 0-23/3 * * *"

action 1 syslog priority warnings msg "EEM runs every 3h"

The trouble is that's running every minute:

*Dec 15 15:44:00.014: %HA_EM-4-LOG: Test-3h: EEM runs every 3h

*Dec 15 15:45:00.034: %HA_EM-4-LOG: Test-3h: EEM runs every 3h

I am running v3:


show event manager version

Embedded Event Manager Version 3.00

It's probably a syntax error, still cannot see it...

Joe Clarke Sat, 12/15/2012 - 13:48

This thread is resolved.  You should be opening new threads for new questions.

pedro juan roig roig Sun, 12/23/2012 - 09:03

Hi Florin,

I am looking for some info about EEM script scheduling, and I think your problem was that you had to replace the first * for a 0. Anyways, if you opened a new thread for this, could you give me the url of that thread, just to check the comments?

Kind Regards,

Joe Clarke Sun, 12/23/2012 - 09:28

You could also start a thread asking your specific question.  It's free to start new thread :-).

pedro juan roig roig Sun, 12/23/2012 - 09:58

Hi Joseph,

I just liked the question and I just wanted to follow up. I am going to start the new "free" thread

Kind Regards,

Actions

This Discussion