cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
15196
Views
15
Helpful
16
Replies

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

thomasdzubin
Level 1
Level 1

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 thomas@dzubin.com

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?

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

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.

View solution in original post

16 Replies 16

Joe Clarke
Cisco Employee
Cisco Employee

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.

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.

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"?

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#

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

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.

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.

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.

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

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...

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

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,

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

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,

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: