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.
In this example, the start method for this service is named periodic-ex. Copy this executable to /lib/svc/method/periodic-ex.
In this example, the service name is site/periodic-example. 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/periodic-example.xml -s service-name=site/periodic-example \ > -s start-method=/lib/svc/method/periodic-ex -s timeout=180 \ > -s period=3600 -s delay=15 -s jitter=5
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.
The /tmp/periodic-example.xml manifest is shown in Example 4, Example Periodic Service Manifest.
Verify that the content of the /tmp/periodic-example.xml manifest is what you need. You might want to make changes such as add a method_context element in the periodic_method element.
Add comments and fill out template elements to describe what the service does and how the properties of the service are used.
$ svccfg validate /tmp/periodic-example.xml
$ cp /tmp/periodic-example.xml /lib/svc/manifest/site/periodic-example.xml
$ svcadm restart manifest-import
Verify that the new service exists and is in the expected state.
$ svcs periodic-example $ svcs -l periodic-example $ svcprop -p periodic periodic-example:default
The example in this procedure produced the following manifest:
<?xml version="1.0" ?> <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> <!-- Manifest created by svcbundle (2020-Oct-01 16:28:06-0700) --> <service_bundle name="site/periodic-example" type="manifest"> <service name="site/periodic-example" version="1" type="service"> <!-- The following dependency keeps us from starting until the multi-user milestone is reached. --> <dependency name="multi_user_dependency" grouping="require_all" restart_on="none" type="service"> <service_fmri value="svc:/milestone/multi-user"/> </dependency> <periodic_method delay="15" jitter="5" recover="false" persistent="false" timeout_seconds="180" exec="/lib/svc/method/periodic-ex" period="3600"/> <instance name="default" enabled="true"/> <template> <common_name> <!-- Replace loctext content with a short name for the service. --> <loctext xml:lang="C"> site/periodic-example </loctext> </common_name> <description> <!-- Replace loctext content with a brief description of the service --> <loctext xml:lang="C"> The site/periodic-example service. </loctext> </description> </template> </service> </service_bundle>