Go to main content

Developing System Services in Oracle® Solaris 11.3

Exit Print View

Updated: September 2018
 
 

Creating a Scheduled Service Using the Service Bundle Generator Tool

When you use the svcbundle command to create a scheduled service, you must specify the interval property as well as both the service-name and start-method properties. By default, svcbundle creates a transient service. When you specify -s period, svcbundle creates a periodic service.

How to Create a Scheduled Service Using svcbundle

  1. Copy the start method to the standard location.

    In this example, the start method for this service is named sched_ex. Copy this executable to /lib/svc/method/sched_ex.

  2. Create an initial manifest.

    In this example, the service name is site/sched_ex. Specify an interval for the start method scheduling. Do not specify any of the following properties: bundle-type, duration, model, rc-script, refresh-method, or stop-method.

    $ svcbundle -o /tmp/sched_ex.xml -s service-name=site/sched_ex \
          -s start-method=/lib/svc/method/sched_ex -s interval=week

    When you specify the interval property, svcbundle creates a scheduled_method element, which causes the restarter for the service to be set to the periodic restarter when the manifest is imported. The value of the interval property becomes the value of the interval attribute of the scheduled_method element. The value of the start-method property becomes the value of the exec attribute of the scheduled_method element.

  3. Make any necessary changes to the manifest.

    Verify that the content of the /tmp/ex_svc.xml manifest is what you need. You might want to make changes such as the following:

    • Specify additional constraints in the scheduled_method element.

    • Specify additional property groups of type schedule, as described in Scheduling Invocations at Irregular Intervals.

    • Add a method_context element in the scheduled_method element.

    • Change the value of the enabled attribute of the default instance from true to false.

    Add comments to describe what the service does and how the properties of the service are used.

  4. Verify that the manifest is valid.

    Use the svccfg validate command to make sure the service manifest is valid.

  5. Copy the manifest to the standard directory.
    $ cp /tmp/sched_ex.xml /lib/svc/manifest/site/sched_ex.xml
  6. Import the manifest and start the service.
    $ svcadm restart manifest-import
  7. List the new service.

    Verify that the new service exists and is in the expected state.

    $ svcs sched_ex