Go to main content

Managing System Services in Oracle® Solaris 11.4

Exit Print View

Updated: February 2022
 
 

How to Schedule a Periodic or Scheduled Service

A periodic or scheduled service runs its start method on a cadence or at a time that you specify by setting property values of the service.

  1. Confirm that the service you want to schedule is a periodic or scheduled service.

    The following command lists all periodic and scheduled services on the system because it lists all instances whose restarter is the periodic-restarter service:

    $ svcs -R svc:/system/svc/periodic-restarter:default

    You could also use svcs -l, svcprop, or svccfg to show the value of the general/restarter property.

  2. Show the current schedule for the service.

    The following command shows whether the instance is a periodic service or a scheduled service. A periodic service has a periodic property group, and a scheduled service has a scheduled property group:

    $ svcprop -p periodic -p scheduled FMRI

    If FMRI is a periodic service, the values of the periodic/period property and any other periodic properties that are set are shown. An error message is shown for the scheduled property group.

    If FMRI is a scheduled service, the values of the scheduled/interval and scheduled/frequency properties and any other scheduled properties that are set are shown. An error message is shown for the periodic property group.

  3. Change the schedule.

    Properties that have no value are not shown by the svcprop or svccfg listprop commands. Use the following references to decide which properties to set to achieve the schedule you want:

    If you set a property that has not been set before, you must specify the property type as shown in Example 32, Scheduling the Compliance Assessment Service. If you reset that property value, you do not need to specify the property type again. Also, if you set a property that has not been set before, you will see the following message:

    Type required for new properties.
  4. Read the modified property values.

    Use the svcadm or svccfg command to refresh the service instance. Use the svcprop command again to verify that the periodic or scheduled property values are updated.

  5. Verify that the service instance is online.

    The instance might have been disabled while you were modifying property values, or the instance might have gone into maintenance when you performed the refresh. If the instance is in maintenance, view the log file as described in Viewing Service Log Files. Possible problems include the following:

    • Conflicting properties are set. For example, you cannot set both the scheduled/day_of_month and scheduled/day property values.

    • Not all required properties are set. For example, you cannot set just the day and minute, you must also set the hour.

    For more information about moving a service out of the maintenance state, see How to Repair an Instance That Is in Maintenance.

  6. Verify the schedule.

    The following command shows the next time the service will run:

    $ svcs -o nrun FMRI

    If no schedule is shown, make sure the instance is online.

Example 32  Scheduling the Compliance Assessment Service

The following command shows that the compliance assessment service is currently scheduled to run once each week:

$ svcprop -p scheduled compliance:default
scheduled/frequency integer 1
scheduled/interval astring week

With this schedule, the instance can run at any time on any day the first week. Subsequent runs will then occur some time that same day in future weeks.

The following commands set the instance to invoke its start method some time between 3am and 4am every Wednesday:

$ svccfg -s compliance:default
svc:/application/security/compliance:default> setprop scheduled/day=Wednesday
Type required for new properties.
svc:/application/security/compliance:default> setprop scheduled/day = astring: Wednesday
svc:/application/security/compliance:default> setprop scheduled/hour = integer: 3
svc:/application/security/compliance:default> refresh
svc:/application/security/compliance:default> exit
$ svcs compliance:default
STATE          STIME    FMRI
online         13:16:57 svc:/application/security/compliance:default
$ svcs -o nrun compliance:default
NRUN
 3:27:16