Configuring a Schedule for Executing the Commands or Scripts (SRC CLI)
To periodically execute the SRC CLI commands or scripts according to a given schedule, use the system schedule schedule-name command. You can use the redirection operator (>) with the commands or scripts to redirect the command execution output to a file.
Use the following statements to schedule a repetitive task on an SRC system:
To periodically execute the commands or scripts according to a given schedule:
- In configuration mode, enter the name of the schedule
that is capable of adding schedule entries for the executable scripts
or commands. A schedule name can contain alphanumeric characters only.
In this sample procedure, src1cron is the
name of the schedule.[edit]user@host# edit system schedule src1cron
- (Optional) Enter the day of the week on which you want
the command or script sequence to execute. The default value is *
(asterisk).[edit system schedule src1cron]user@host# set day-of-week day-of-week
- (Optional) Enter the month of the year in which you want
the command or script sequence to execute. The default value is *
(asterisk).[edit system schedule src1cron]user@host# set month month
- (Optional) Enter the day of the month on which you want
the command or script sequence to execute. The default value is *
(asterisk).[edit system schedule src1cron]user@host# set day-of-month day-of-month
- (Optional) Enter the hour of the day at which you want
the command or script sequence to execute. The default value is *
(asterisk).[edit system schedule src1cron]user@host# set hour hour
- (Optional) Enter the minute at which you want the command
or script sequence to execute. The default value is * (asterisk).[edit system schedule src1cron]user@host# set minute minute
Table 1 lists the values allowed for the periodic strings (such as day-of-week, month, day-of-month, hour, and minute).
Table 1: Values Allowed for the Periodic Strings
Options
Values
day-of-week
0–7 (where both 0 and 7 mean Sunday) or SUN-SAT
month
1–12 or JAN-DEC
day-of-month
1–31
hour
0–23
minute
0–59
You can use multiple combinations of the special characters described in Table 2.
Table 2: Available Special Characters
Special Characters
Meaning
*
Indicates all values.
For example, to execute the command or script every hour:
user@host# set hour *
/
Indicates the increments of ranges.
For example, to execute the command or script at the third minute of the hour and every 15 minutes thereafter:
user@host# set minute 3-59/15
,
Indicates to separate the values of a list.
For example, to execute the command or script on Mondays, Wednesdays and Fridays:
user@host# day of week MON,WED,FRI
-
Indicates the ranges.
For example, to execute the command or script every hour from 3 through 10:
user@host# set hour 3-10
- (Optional) Enter the special string values such as reboot, yearly, annually, monthly, weekly, daily, midnight, and hourly at which you want the command or script sequence to
execute.
For example, to execute the command or script at midnight on the first day of each month:
[edit system schedule src1cron]user@host# set special-string monthlyNote: If you configure both special string values and periodic string values (such as day-of-week, month, day-of-month, hour, or minute options), a message indicating that both special strings and periodic strings cannot be defined is displayed when you commit the changes.
Table 3 lists the special string options.
Table 3: Special String Options
Options
Description
reboot
Executes the command or script at boot and reboot of the system.
yearly
Executes the command or script at midnight, January 1 each year.
annually
Executes the command or script at midnight, January 1 each year.
monthly
Executes the command or script at midnight on the first day of each month.
weekly
Executes the command or script at midnight each Sunday.
daily
Executes the command or script at midnight each day.
midnight
Executes the command or script at midnight each day.
hourly
Executes the command or script at on the first second of every hour.
- Configure the complete path of the script to be executed
for the schedule.
Note: The script and command options are mutually exclusive. You cannot configure both options at the same time.
[edit system schedule src1cron]user@host# set script scriptNote: The CLI editing level must be set to expert by using the set cli level expert command for this option.
- Configure the CLI command to be executed for the schedule.
Note:
The script and command options are mutually exclusive. You cannot configure both options at the same time.
Before you configure a CLI command for the schedule, perform the following steps to make sure that you can configure the CLI command as part of the schedule execution:
Enter the CLI command in the shell with the cli –c “command name” option.
Verify whether the CLI command returns the expected output.
[edit system schedule src1cron]user@host# set command command - (Optional) Verify your configuration.user@host# showsrc1cron {command show;day-of-month 7;day-of-week 5;hour 11;minute 0;month 12;}