Service

The TrueNAS CLI guide for SCALE is a work in progress! New namespace and command documentation is continually added and maintained, so check back here often to see what is new!

Service Commands

The service namespace has 10 commands and 12 child namespaces and is based on functions found in the SCALE API and web UI. It provides access to service configuration and validation methods for the 10 service commands. The 12 child namespaces have their own commands.

You can enter commands from the main CLI prompt or from the service namespace prompt.

Get_Instance Command

The get_instance command displays the id, name, and status of a service.

Checking the Status of a Service

Description

The get_instance command requires you to include the id property in the command string. Enter the command, then press Enter. After entering the command correctly, it returns a table with multiple outputs.

Usage

From the CLI prompt, enter:

service get_instance id=number

Where number is the service id. For example, if the ssh service id is 11, enter 11.

Command Example
get_instance id=11
+---------+--------------+
|      id | 11           |
| service | ssh          |
|  enable | false        |
|   state | STOPPED      |
|    pids | <empty list> |
+---------+--------------+

Query Command

The query command displays a simple overview of all services.

Running a Simple Query

Description

The query command does not require entering properties or arguments. Enter the command, then press Enter. After entering the command, it returns a table with multiple outputs.

Usage

From the CLI prompt, enter:

service query

Command Example
service> query
+----+-------------+--------+---------+--------------+
| id | service     | enable | state   | pids         |
+----+-------------+--------+---------+--------------+
| 4  | cifs        | false  | STOPPED | <empty list> |
| 6  | ftp         | false  | STOPPED | <empty list> |
| 7  | iscsitarget | false  | STOPPED | <empty list> |
| 9  | nfs         | false  | STOPPED | <empty list> |
| 10 | snmp        | false  | STOPPED | <empty list> |
| 11 | ssh         | false  | STOPPED | 98638        |
| 14 | ups         | false  | STOPPED | <empty list> |
| 18 | smartd      | false  | STOPPED | 3079         |
| 26 | glusterd    | false  | STOPPED | <empty list> |
+----+-------------+--------+---------+--------------+

Reload Command

The reload command reloads a specified service.

Reloading a Service

Description

The reload command requires you to include the service property in the command string. Enter the command string, then press Enter. After entering the command correctly, it returns either a true or false output. True indicates the service reloaded. False indicates the service did not reload.

Usage

From the CLI prompt, enter:

service reload service=name

From the service prompt, enter:

reload service=name

Where name is the service name. For example, enter ssh for the ssh service.

Command Example
reload service=ssh
true

Restart Command

The restart command restarts a specified service.

Restarting a Service

Description

The restart command requires you to include the service property in the command string. Enter the command string, then press Enter. After entering the command correctly, it returns either a true or false output. True indicates the service restarted successfully. False indicates the service did not restart.

Usage

From the CLI prompt, enter:

service restart service=name

Where name is the service name. For example, enter ssh for the ssh service.

Command Example
restart service=ssh
true

Start Command

The start command restarts a specified service.

Restarting a Service

Description

The start command requires you to include the service property in the command string. Enter the command string, then press Enter. After entering the command correctly, it returns either a true or false output. True indicates the service started successfully. False indicates the service did not start.

Usage

From the CLI prompt, enter:

service start service=name

Where name is the service name. For example, enter ssh for the ssh service.

Command Example
start service=ssh
true

Started Command

The started command verifies whether a start command succeeded for a specified service.

Verifying a Service Started

Description

The started command requires you to include the service option in the command string. Enter the command string, then press Enter. After entering the command correctly, it returns either a true or false output. True indicates the service started successfully. False indicates the service did not start.

Usage

From the CLI prompt, enter:

service started service=name

Where name is the service name. For example, enter ssh for the ssh service.

Command Example
started service=ssh
true

Started_or_Enabled Command

The started_or_enabled command displays whether a service starts automatically upon reboot or is running.

Verifying a Service State and Enable Status

Description

The started_or_enabled command requires you to include the service option in the command string. Enter the command string, then press Enter. After entering the command correctly, it returns either a true or false output. True indicates the service restarts automatically and/or is running. False indicates the service is not running and does start automatically.

Usage

From the CLI prompt, enter:

service started_or_enabled service=name

Where name is the service name. For example, enter ssh for the ssh service.

Command Example
started_or_enabled service=ssh
true

Stop Command

The stop command stops a specified service.

Stopping a Service

Description

The stop command requires you to include the service option in the command string. Enter the command string, then press Enter. After entering the command correctly, it returns either a true or false output. True indicates the service started or is running. False indicates the service stopped or is not running.

Usage

From the CLI prompt, enter:

service stop service=name

Where name is the service name. For example, enter ssh for the ssh service.

Command Example
stop service=ssh
false

Terminate_Process Command

The terminate_process command forces a service to stop and disables it.

Stopping a Service

Description

The terminate_process command requires you to include the pid proptery in the command string. You can also include the timeout property (not required) to specify the amount of time (in seconds) the system should attempt to terminate the service. Enter the command string, then press Enter. After entering the command correctly, it returns either a true or false output. The command only returns true to show that the service stopped or is not running.

Usage

From the CLI prompt, enter:

service terminate_process pid=number timout=number

Where number is the pid (process id) and the number of seconds before the task times out. For example, 108648 and 1 to try terminating process 108648 for 10 seconds.

Command Example
terminate_process pid=108648 timeout=true
true

Update Command

The update command updates the service specified and lets you decide whether or not you want a service to start automatically upon system reboot.

Updating a Service

Description

The update command requires you to include the id_or_name and enable property in the command string. Enter the command string, then press Enter. The command returns an empty line.

Usage

From the CLI prompt, enter:

service update id_or_name=number/name enable=true/false

Where:

  • number/name is the service id name. For example, enter 11 or ssh for the ssh service.
  • true/false enables the start automatically feature if the value is true or disables start automatically if the value is false.

Command Example
update id_or_name=ssh enable=true

Service Namespaces

The following articles provide information on service child namespaces:

  • Cluster: Provides information about the service cluster namespace in the TrueNAS CLI. Includes command syntax and common commands.

    • CTDB: Provides information about the service ctdb namespace in the TrueNAS CLI. Includes command syntax and common commands.

      • FTP: Provides information about the service ftp namespace in the TrueNAS CLI. Includes command syntax and common commands.

        • Gluster: Provides information about the service gluster namespace in the TrueNAS CLI. Includes command syntax and common commands.

          • IPMI: Provides information about the service ipmi namespace in the TrueNAS CLI. Includes command syntax and common commands.

            • NFS: Provides information about the service nfs namespace in the TrueNAS CLI. Includes command syntax and common commands.

              • SMB: Provides information about the service smb namespace in the TrueNAS CLI. Includes command syntax and common commands.

                • SNMP: Provides information about the service snmp namespace in the TrueNAS CLI. Includes command syntax and common commands.

                  • SSH: Provides information about the service ssh namespace in the TrueNAS CLI. Includes command syntax and common commands.

                    • UPS: Provides information about the service ups namespace in the TrueNAS CLI. Includes command syntax and common commands.

                      • VM: Provides information about the service vm namespace in the TrueNAS CLI. Includes command syntax and common commands.

                        • SMART: Provides information about the service smart namespace in the TrueNAS CLI. Includes command syntax and common commands.