Go to main content

Developing System Services in Oracle® Solaris 11.3

Exit Print View

Updated: September 2018
 
 

Creating a Periodic Service Using the Service Bundle Generator Tool

When you use the svcbundle command to create a periodic service, you must specify the period 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 Periodic Service Using svcbundle

  1. Copy the start method to the standard location.

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

  2. Create an initial manifest.

    In this example, the service name is site/per_ex. Specify a period 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/per_ex.xml -s service-name=site/per_ex \
          -s start-method=/lib/svc/method/per_ex -s period=30

    When you specify the period property, svcbundle creates a periodic_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 period property becomes the value of the period attribute of the periodic_method element. The value of the start-method property becomes the value of the exec attribute of the periodic_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:

    • Add values for delay, jitter, and timeout_seconds in the periodic_method element.

    • Add a method_context element in the periodic_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/per_ex.xml /lib/svc/manifest/site/per_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 per_ex