The svcs command is the primary command for listing service instance states and status.
See Service States for descriptions of the states shown in these examples.
Example 1 Listing All Enabled ServicesWith no options or arguments, the svcs command lists all service instances that are enabled on this system, as well as instances that are temporarily disabled.
Service instances in the disabled state in this listing will be enabled on the next boot of the system. Instances in the legacy_run state are not managed by SMF. See Configuration Files and SMF Services for more information about these legacy services. See Getting More Information About Service States if you have services in the maintenance, degraded, or offline states.
The STIME column shows the time the instance entered the listed state. If the instance entered this state more than 24 hours ago, the STIME column shows the date.
$ svcs STATE STIME FMRI legacy_run Sep_09 lrc:/etc/rc2_d/S47pppd legacy_run Sep_09 lrc:/etc/rc2_d/S81dodatadm_udaplt legacy_run Sep_09 lrc:/etc/rc2_d/S89PRESERVE disabled Sep_09 svc:/system/vbiosd:default online Sep_09 svc:/system/early-manifest-import:default online Sep_09 svc:/system/svc/restarter:default ...Example 2 Listing All Installed Services
To list all service instances that are installed on this system, including disabled instances that will not be enabled automatically on next boot, use the svcs -a command.
$ svcs -a
An asterisk (*) is appended to the state for service instances that are transitioning from the listed state to another state. For example, offline* probably means the instance is still executing its start method.
A question mark (?) is displayed if the state is absent or unrecognized.
Example 3 Listing All Instances of a ServiceWith a service name specified, the svcs command lists all instances of a service. See Showing Selected Service Information for information about the -o option.
$ svcs -Ho inst identity node domain
The svcs -l command shows a long listing for each specified service instance including more detailed information about the instance state, paths to the log file and configuration files for the instance, dependency types, dependency restart attribute values, and dependency state. The following example shows that all of the required dependencies of this service instance are online. The one dependency that is disabled is an optional dependency. For information about dependency types and restart attribute values, see Showing Service Dependencies. In svcs -l output, states other than those described in Service States are possible for dependencies. See the svcs(1) man page for descriptions. The following example also shows that the specified service instance is temporarily enabled, is online, and the service is a contract type service. See Service Models for definitions of service types. If the state value has a trailing asterisk, for example offline*, then the instance is in transition, and the next state field shows a state value instead of none. The state_time is the time the instance entered the listed state.
$ 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)Example 4 Showing Processes Started by a Contract Service
Use the svcs -p command to show the process IDs and command names of processes started by a contract service instance. The net-snmp service manages the /usr/sbin/snmpd SNMP agent that collects information about a system through a set of Management Information Bases (MIBs).
$ svcs -p net-snmp STATE STIME FMRI online 17:57:26 svc:/application/management/net-snmp:default 17:57:26 5022 snmpdExample 5 Showing a Contract Service Restarting Automatically After Process Stop
Contract service instances are automatically restarted if the contract empties. SMF also attempts to restart processes associated with a contract service instance as part of automatic recovery from hardware or software failure events. The following example shows that after the /usr/sbin/snmpd process is killed, it is automatically restarted with a new process ID. The net-snmp:default instance is still online and has a new start time.
$ kill 5022 $ svcs -p net-snmp STATE STIME FMRI online 17:57:59 svc:/application/management/net-snmp:default 17:57:59 5037 snmpd
Output from the svcs command can be very useful for piping to other commands or using in scripts. The -o option of the svcs command enables you to specify the columns of information you want and the order of the columns. You can output the service name and instance name in separate columns, the current state and next state of the service, and the contract ID, for example. With the -s and -S options, you can specify the sort order of the output for one or more columns. See the COLUMNS section of the svcs(1) man page for a list of available columns. Multiple -s options behave additively.
Three additional pieces of information can be shown for periodic services. For information about periodic services, see Chapter 3, Creating a Service to Run Periodically in Developing System Services in Oracle Solaris 11.3 and the svc.periodicd(1M) man page.
The last time the start method of this periodic service instance ran. Service instances that are not periodic display a hyphen character (-) in this column.
The next time the start method of this periodic service instance is scheduled to run. Service instances that are not periodic display a hyphen character (-) in this column.
The auxiliary state of the service instance. Service instances that are not periodic instances use this property to show the reason that the instance made its most recent transition. Instances that are not periodic instances almost always show dependencies_satisfied as the value of this property, since this is usually the reason the instance transitioned from the offline to the online state. Periodic service instances can display either running or scheduled in this column to indicate whether the instance is waiting between start method executions. See Specifying the periodic_method Element in Developing System Services in Oracle Solaris 11.3 for more information.