Go to main content

Managing System Information, Processes, and Performance in Oracle® Solaris 11.3

Exit Print View

Updated: January 2019
 
 

Scheduling Repetitive System Tasks Using SMF

The following section includes information about how to create, modify, and display SMF service instances. It also covers information about SMF access controls:

How SMF Handles Scheduling

Each SMF scheduled service is managed by a restarter. The master restarter svc.startd manages states for the entire set of service instances and their dependencies. The master restarter acts on behalf of its services and on delegated restarters that can provide specific execution environments for certain application classes. For example, inetd is a delegated restarter that provides its service instances with an initial environment. Each service instance delegated to inetd is in the online state. While the daemon of a particular instance might not be running, the instance is available to run. As dependencies are satisfied when instances move to the online state, svc.startd invokes start methods of other instances which may overlap. See the smf_restarter(5) man page to view the configuration settings for all SMF restarters.

Each service or service instance must define a set of methods that start, stop, and, refresh the service. For a complete description of the method conventions for svc.startd and similar restarters, see the smf_method(5) man page. Administrative methods, such as for the capture of legacy configuration information into the repository, are discussed in the svccfg(1M) man page.

Scheduling Method and Time Values for SMF

A scheduled service instance in SMF requires a specific time which is delegated by the scheduled_method element. The scheduled_method element specifies both method and scheduling information for scheduled services.

Table 7  Acceptable Numerical Values for SMF Scheduling
Time Field
Numerical Values
Minute
0-59
Hour
0-23
Day of month
1-31
Month
1-12
Day of week
0-6 (0 = Sunday)

For more information on constraints and how to specify the scheduled_method element, see Specifying the scheduled_method Element in Developing System Services in Oracle Solaris 11.3.

Examples of SMF Manifests

Example 33  Creating an SMF Scheduled Service

The following example shows how to create an SMF scheduled service instance to run automatically at 1:00 a.m. every Sunday morning.

<?xml version='1.0'?>
<!DOCTYPE service_bundle
  SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='site/sample-periodic-svc'>
    <service type='service' version='1' name='site/sample-periodic-svc'>

        <instance name='default' enabled='false'>

            <scheduled_method
                schedule='month'
                day='0'
                hour='1'
                minute='0'
                exec='/usr/bin/scheduled_service_method'
                timeout_seconds='0'>
                    <method_context>
                        <method_credential user='root' group='root' />
                    </method_context>
            </scheduled_method>

        </instance>
    </service>
</service_bundle>

For more step-by-step information on how to create a periodic service, see Chapter 3, Creating a Service to Run Periodically in Developing System Services in Oracle Solaris 11.3.