Managing scheduled jobs
Scheduling a job to run automatically
A job, that is command, can be scheduled to run on a recurring basis or after certain events.
Use the following command to schedule a job:
job <name> at job <Name> at [HH:]MM [on [MM/]DD] [config-save] <Command-str> job <Name> at <Event> [config-save] <Command-str>
job | Schedule a command to run automatically in the future. |
Name | The name of the job to add or delete. |
at | Schedule when the job runs. |
reboot | Run the job as soon as possible after every switch boot. |
[HH:]MM | The time when the job has to run. |
on | Schedule the job to run on specified days. |
MM/DD | The date when the job has to run. |
<-31--1> | The day relative to the end of the month when the job has to run. |
<1-31> | The day of the month when the job has to run. |
WEEKDAY-LIST | The days of the week when the job has to run. |
config-save | Save configuration changes made by the job. |
Command-str | The command to execute when this job runs. |
NOTE: This command uses a new “weekday list” token type. A weekday list represents one or more days of the week and is stored internally. It allows users to specify a list of individual days or a range of days and use abbreviations. Examples of this weekday list are:
| |
Examples
A pair of jobs that disable PoE during non-working hours
Switch(config)# job poe-on at 8:00 on mon-fri config-save "interface 1-24 power-over-ethernet" Switch(config)# job poe-off at 17:00 on mon-fri config-save "no interface 1-24 power-over-ethernet"
A pair of jobs that block access to a server during weekends
Switch(config)# ip access-list extended block-server Switch(config-ext-nacl)# deny ip any host 10.0.1.80 Switch(config-ext-nacl)# permit ip any any Switch(config-ext-nacl)# exit Switch(config)# job allow at 8:00 on mon config-save "no interface 1-24 ip access-group block-server in" Switch(config)# job deny at 17:00 on fri config-save " interface 1-24 ip access-group block-server in"
Deleting a scheduled job
Use the command no job <name>
to
delete a scheduled job. The name argument
specifies the job to be deleted.
Delete a scheduled job named “baz”
switch# show job Job Scheduler Status and Configuration Scheduler Status : Waiting for the system time to be set Event or Save Name Time Cfg Command -------------------- ------------- ---- ------------------------------------- Burrrrrrrrrrrrrrr... reboot Yes chassislocate blink baz reboot No show time foo 17:00 SxTWTxS No savepower led switch# no job baz
Viewing scheduled jobs
Do one of the following:
Use the command
show job <Name>
to view details of a specific scheduled job.Use the command
show job
to view a list of all the scheduled jobs.
Names and commands that are longer than their column width are truncated with an ellipsis in the display. To assist administrators in diagnosing problems with jobs, there is a detail view for a single job. If the last job run produced any output, the first 255 characters of that output will be shown from the last job run whether that job was successful or not. A successful run will overwrite the error output from a previous failed run.
Examples
View a list of the scheduled jobs
switch# show job Job Scheduler Status and Configuration Scheduler Status : Waiting for the system time to be set Event or Save Name Time Cfg Command -------------------- ------------- ---- ------------------------------------- Burrrrrrrrrrrrrrr... reboot Yes chassislocate blink baz reboot No show time foo 17:00 SxTWTxS No savepower led
Time adjustments and scheduling jobs
Daylight savings time adjustments
When daylight savings time (DST) begins (“spring forward”), the local time jumps from 0200 to 0300. The Job Scheduler “catches up” by running all jobs scheduled between 0200 and 0300 the next time it wakes up. This prevents jobs from being skipped when they appear in the 0200 to 0300 time frame.
When daylight savings time (DST) ends (“fall back”), the local time jumps from 0200 to 0100. The Job Scheduler skips all jobs scheduled between 0100 and 0200 to allow local time to catch up. Those jobs already ran once before DST ended will not repeat.
NOTE: If an administrator configures a new job during the repeat of the 0100 to 0200 hour on the day DST ends, the new job will not be run because the Job Scheduler skips that hour. | |
External adjustments
External adjustments to the system time can happen to correct for clock drift or for other administrative reasons. The new time update can come from SNTP, from a configuration command at the CLI, or from an SNMP SET of the system time MIB object. When a time adjustment takes place, the Job Scheduler task is called with the new clock value. Jobs scheduled during a time clock jump forward are run while any jobs scheduled during a time clock jump back are skipped.
Adjustment of more than 10 minutes are considered a major change and reset the Job Scheduler. Any jobs scheduled during a time clock jump forward are skipped while any jobs scheduled during a time clock jump back are repeated.
Calendar conflicts
Because the Job Scheduler MIB is more flexible than the CLI scheduling grammar, it is possible to create job schedules via SNMP that cannot be displayed by the CLI. The following rules are imposed on MIB values to limit them to what the CLI can display.
If any bits are set in hpicfJobSchedulerEvent, all Calendar values are ignored. They may be set with SNMP, but are ignored when looking for jobs to run. The Calendar values are also ignored by the command
show running-config
.If any bit is set in CalendarDayOfWeek, then CalendarMonth and CalendarDayOfMonth are ignored.
If no bits are set in CalendarDayOfWeek or CalendarDayOfMonth, then CalendarMonth is ignored.
Only 1 bit may be set in the CalendarMonth, CalendarDayOfMonth, CalendarHour, and CalendarMinute objects. Attempting to set a value with more than 1 bit returns an InconsistentValue error.
If no bits are set in CalendarHour and CalendarMinute, the job is considered to be in a transition state and not valid. This could happen when an SNMP management application is creating a job one object at a time. Jobs in this state are ignored by the scheduler and by the command
show running-config
.
The Job Scheduler
The Job Scheduler provides administrators the ability to schedule recurring commands or “jobs” on their switch. A feature of the Job Scheduler is the ability to schedule a command to run on a recurring basis or after certain events. For example, a command can be triggered to run by certain predefined events such as switch reboot.
There is no prompt for user input with this feature. Administrators using this feature can schedule commands such as enabling or disabling ports, turning on or off LEDs and Power-Over-Ethernet commands. All commands run with manager privilege in configuration context.
Jobs that are scheduled can be viewed or deleted.