Go to main content

Managing System Services in Oracle® Solaris 11.4

Exit Print View

Updated: February 2022
 
 

Starting a Service

A service instance that is in any of the following states is already enabled and does not need to be started: degraded, maintenance, offline, online. If the instance you want to start is in the degraded, maintenance, or offline state, see Repairing an Instance That Is Degraded, Offline, or in Maintenance. If the instance you want to start is in the disabled state, enable the instance as shown in the following procedure. When you enable an instance, the restarter for that instance attempts to transition the instance to the online state.

How to Enable a Service Instance

  1. Check the instance state and dependencies.

    Check that the instance is currently disabled and that all of its required dependencies are running (in the online or degraded state).

    $ svcs -l FMRI
  2. Enable the instance.

    The restarter for the service attempts to bring the specified instance to the online state.

    An instance can be permanently or temporarily enabled. Permanent enable is persistent across system reboot and is the default. Temporary enable lasts only until reboot.

    • Permanently enable the instance.
      $ svcadm enable FMRI
    • Temporarily enable the instance.

      Use the -t option to specify temporary enable.

      $ svcadm enable -t FMRI

      If you want an instance to run now but not run on next reboot, make sure the instance is disabled, and then temporarily enable the instance. To verify that the instance is temporarily enabled, use the svcs -l command and check the enabled row:

      enabled      true (temporary)
    • Synchronously enable the instance.

      If you specify the -s option, svcadm enables the instance and waits for the instance to enter the online or degraded state before returning. The svcadm command returns when the instance reaches an online state or when it determines that the instance requires administrator intervention to reach an online state.

      Use the -T option with the -s option to specify an upper bound in seconds to make the transition or determine that the transition cannot be made.

      $ svcadm enable -sT 10 FMRI
  3. Verify that the instance is online.
    $ svcs FMRI

    If the instance is in the degraded, maintenance, or offline state, see Repairing an Instance That Is Degraded, Offline, or in Maintenance.

Example 16  Enabling a Service Instance Permanently

The following command shows that the pkg/mirror:default service instance is currently disabled, and all of its required dependencies are online.

$ svcs -l pkg/mirror
fmri         svc:/application/pkg/mirror:default
name         IPS Repository Mirror
enabled      false
state        disabled
next_state   none
state_time   September 17, 2013 07:16:52 AM PDT
restarter    svc:/system/svc/restarter:default
manifest     /lib/svc/manifest/application/pkg/pkg-mirror.xml
dependency   require_all/error svc:/milestone/network:default (online)
dependency   require_all/none svc:/system/filesystem/local:default (online)
dependency   optional_all/error svc:/system/filesystem/autofs:default (online)
dependency   require_all/none svc:/application/pkg/repositories-setup (online)

The following command enables the pkg/mirror:default instance. In this case, the svcadm command returns because the pkg/mirror:default instance is successfully enabled.

$ svcadm enable -sT 10 pkg/mirror:default
$ svcs pkg/mirror
STATE          STIME    FMRI
online         22:03:53 svc:/application/pkg/mirror:default
Example 17  Enabling a Service Instance Temporarily

The following command shows that the net-snmp:default service instance is currently disabled, and all of its required dependencies are online. The one dependency that is disabled is an optional dependency.

$ svcs -l net-snmp
fmri         svc:/application/management/net-snmp:default
name         net-snmp SNMP daemon
enabled      false
state        disabled
next_state   none
state_time   September 17, 2013 05:56:39 PM PDT
logfile      /var/svc/log/application-management-net-snmp:default.log
restarter    svc:/system/svc/restarter:default
contract_id
manifest     /etc/svc/profile/generic.xml
manifest     /lib/svc/manifest/application/management/net-snmp.xml
dependency   require_all/none svc:/system/filesystem/local (online)
dependency   optional_all/none svc:/milestone/name-services (online)
dependency   optional_all/none svc:/system/system-log (online)
dependency   optional_all/none svc:/network/rpc/rstat (disabled)
dependency   require_all/restart svc:/system/cryptosvc (online)
dependency   require_all/restart svc:/milestone/network (online)
dependency   require_all/refresh file://localhost/etc/net-snmp/snmp/snmpd.conf (online)
dependency   require_all/none svc:/milestone/multi-user (online)

After enabling the instance using the -t option as shown in the following example, the instance is temporarily enabled, is online, and has a contract ID because it has started the snmpd process, as shown by the svcs -p command.

$ svcadm enable -t net-snmp:default
$ svcs -l net-snmp
fmri         svc:/application/management/net-snmp:default
name         net-snmp SNMP daemon
enabled      true (temporary)
state        online
next_state   none
state_time   September 17, 2013 05:57:26 PM PDT
logfile      /var/svc/log/application-management-net-snmp:default.log
restarter    svc:/system/svc/restarter:default
contract_id  160
manifest     /etc/svc/profile/generic.xml
manifest     /lib/svc/manifest/application/management/net-snmp.xml
dependency   require_all/none svc:/system/filesystem/local (online)
dependency   optional_all/none svc:/milestone/name-services (online)
dependency   optional_all/none svc:/system/system-log (online)
dependency   optional_all/none svc:/network/rpc/rstat (disabled)
dependency   require_all/restart svc:/system/cryptosvc (online)
dependency   require_all/restart svc:/milestone/network (online)
dependency   require_all/refresh file://localhost/etc/net-snmp/snmp/snmpd.conf (online)
dependency   require_all/none svc:/milestone/multi-user (online)
$ svcs -p net-snmp
STATE          STIME    FMRI
online         17:57:26 svc:/application/management/net-snmp:default
               17:57:26     5022 snmpd