Go to main content

Developing System Services in Oracle® Solaris 11.4

Exit Print View

Updated: November 2020
 
 

Specifying the scheduled_method Element

The scheduled_method element can be specified within a service element or within an instance element. The scheduled_method element specifies both start method and scheduling information for scheduled services and can have the attributes that are described in this section. The interval and exec attributes are required. The method information is the same for a scheduled_method element as for a periodic_method element.

Example 5  Scheduled Service scheduled_method Element

The following example shows the scheduled_method element in a scheduled service. In this example, the periodic restarter executes /usr/bin/scheduled-ex every Sunday at 3:15am and does not perform an off-schedule execution if a scheduled execution is missed, for example due to system downtime.

                <scheduled_method
                    interval='week'
                    day='Sunday'
                    hour='3'
                    minute='15'
                    recover='false'
                    exec='/usr/bin/scheduled-ex'
                    timeout_seconds='0'>
                        <method_context>
                                <method_credential user='root' group='root' />
                        </method_context>
                </scheduled_method>

Scheduled Service Scheduling Constraints Attributes

When specifying values of scheduling constraints for a scheduled service, note the following:

  • Specify the fewest scheduling constraints that are required to schedule the task. Constraints that represent shorter time periods than the interval value specify more precisely when in the interval to invoke the start method for the instance.

  • Specify a continuous set of scheduling constraints from the constraint that represents the longest time to the constraint that represents the shortest time. For example, you can specify just a week_of_year value, but you cannot specify a week_of_year and an hour unless you also specify a day_of_month or day.

  • You can specify constraints that represent time periods that are equal to or longer than the interval value if the value of frequency is greater than 1. See Scheduling Executions of a Scheduled Service Start Method for more information about how to use these constraints.

For svcprop and svccfg, the following attributes of the scheduled_method element are accessed as properties in the scheduled property group.

interval

Required. Value type: astring. The base length of time between invocations of the service start method, depending on the value of frequency. The value of interval is one of the following: year, month, week, day, day_of_month, hour, minute.

frequency

Optional. Value type: count. Default value: 1. The number of intervals that must occur before the start method is executed by the periodic restarter. For example, if interval is week and frequency is 4, the start method will be invoked every fourth week. Note that every fourth week is different from the fourth week of every month because some months have five weeks.

If the value of frequency is greater than 1, all constraints from year down to the same length of time as the interval value must be specified. For example, if interval is week, values must be specified for year and week_of_year. See Scheduling One Invocation Per Multiple Intervals for examples.

timezone

Optional. Value type: astring. Default value: the system time zone. The time zone to use to create and interpret schedules. Use this attribute to define a schedule relative to a time zone other than the time zone configured for the system.

year

Value type: count. A Gregorian calendar year. The year in which to invoke the start method.

week_of_year

Value type: integer. The ordinal number of the week in an ISO 8601 week date year. Valid values are 1 through 53 and -1 through -53. A negative number specifies weeks backward from the last week of the year. For a year that has 52 weeks, -1 is the same as 52, and for a year that has 53 weeks, -1 is the same as 53. If you specify 53 or -53, the start method will not run in years that have only 52 weeks.

The week_of_year and month attributes are mutually exclusive.

month

Value type: astring. A month of a Gregorian year. Valid values are 1 through 12, -1 through -12, the C Locale full name of the month, or the C Locale three-character abbreviation for the name of the month. A negative number specifies months backward from the last month of the year. C Locale names are not case sensitive.

The week_of_year and month attributes are mutually exclusive.

day_of_month

Value type: integer. A day in a Gregorian calendar month. Valid values are 1 through 31 and -1 through -31. A negative number specifies days backward from the last day of the month. If you specify a day that does not exist in a particular month, for example 31 or -1 for April, the start method will run on the last day of that month.

The day_of_month and day attributes are mutually exclusive.

weekday_of_month

Value type: integer. The ordinal number of the week in a month in which the specified day (see day) occurs. Valid values are 1 through 5 and -1 through -5. A negative number specifies weeks backward from the last week of the month. For example, the third Thursday in the month (3) is different from the next-to-last Thursday in the month (-2) if the month has five Thursdays. If you specify 5 or -1, the start method will not run in months that have only four of the specified day.

If weekday_of_month is specified, day must also be specified.

day

Value type: astring. A day in an ISO 8601 standard week. Valid values are 1 through 7 and -1 through -7, the C Locale full name of the day, or the C Locale three-character abbreviation of the name of the day. A negative number specifies days backward from the end of the week. C Locale names are not case sensitive.

The day_of_month and day attributes are mutually exclusive.

hour

Value type: integer. An hour of an ISO 8601 standard day. Valid values are 0 through 23 and -1 through -24. A negative number specifies hours backward from the end of the day. If the scheduled day includes a transition between standard time and daylight saving time, the specified hour might occur two times that day or might not occur at all that day. If the specified hour occurs more than one time on the scheduled day, the start method will run only on the first occurrence of the hour. If the specified hour does not occur on the scheduled day, the start method will run in the following hour.

minute

Value type: integer. A minute of an hour. Valid values are 0 through 59 and -1 through -60. A negative number specifies minutes backward from the end of the hour.

Other Scheduled Service Scheduling Attributes

For svcprop and svccfg, the recover attribute of the scheduled_method element is accessed as a property in the scheduled property group.

recover

Optional. Value type: boolean. Default value: false. Specifies whether the instance should have a recovery execution if an invocation was lost during system downtime.

If the value of the recover attribute is true, the periodic restarter invokes the start method for the instance as soon as possible as the instance emerges from system downtime. Subsequent invocations occur according to the specified scheduling constraints.

If the value of the recover property is false, no recovery invocation is executed. Invocations continue according to the specified scheduling constraints.

Scheduled Service Start Method Attributes and Context

exec

Required. Value type: astring. The action to take, which must be suitable to pass to the exec system call. See the smf_method(7) man page. See additional description in Specifying the periodic_method Element.

timeout_seconds

Optional. Value type: integer. The number of seconds to wait for the start method action to complete. Use a value of 0 or -1 to specify an infinite timeout.

The timeout_seconds attribute value is required by the exec_method element. If you do not specify a value for the timeout_seconds attribute in this scheduled_method element, the value for the exec_method element is assumed to be infinite. See Scheduling After Start Method Problems for a description of start method scheduling if the start method runs longer than the specified timeout_seconds value or if a contracted process still exists when the periodic restarter attempts to invoke the start method in the next scheduled interval.

method_context element

Optional. See the Method Context section of the smf_method(7) man page.