If a unit service takes longer than the default timeout to stop or start the corresponding service, it goes into the Failed state

Sometimes, the unit service file may take more time than the default timeout value to stop or to start the service. In this scenario, the service goes into the 'failed' state.

For example:

( root@localhost-vm1 )[ ~ ] # systemctl status vcs
vcs.service - VERITAS Cluster Server (VCS)
Loaded: loaded (/opt/VRTSvcs/bin/vcs; enabled)
Active: failed (Result: timeout) since Tue 2017-04-25 21:01:39 IST;
 6s ago
Process: 26546 ExecStart=/opt/VRTSvcs/bin/vcs start 2>&1
 (code=exited, status=0/SUCCESS)
Apr 25 21:00:09 localhost systemd[1]: Stopping VERITAS Cluster
 Server (VCS)...
Apr 25 21:01:07 localhost AgentFramework[26625]: VCS ERROR
 V-16-20006-1005 CVMCluster:cvm_clus:monitor:node - st...ster
 reason: user initiated stop
Apr 25 21:01:07 localhost AgentFramework[26625]: VCS ERROR
 V-16-2-13066 Thread(140447847638784) Agent is calling...ted.
Apr 25 21:01:07 localhost Had[26588]: VCS ERROR V-16-2-13066
 (localhost) Agent is calling clean for reso...leted.
Apr 25 21:01:39 localhost systemd[1]: vcs.service stopping timed
 out. Terminating.
Apr 25 21:01:39 localhost systemd[1]: Stopped VERITAS Cluster
 Server (VCS).
Apr 25 21:01:39 localhost systemd[1]: Unit vcs.service entered
 failed state.
Hint: Some lines were ellipsized, use -l to show in full.

Recommended action

To work around this issue, add a custom timeout value (in seconds) to the unit service file. The TimeoutSec parameter lets you configure the amount of time that the system must wait before it reports that the start or stop operation of a service is has failed.

The following example displays the parameter that is used to set a custom timeout in the unit service file:

( root@localhost-vm1 )[ ~ ] # vim /usr/lib/systemd
/system/vcs.service
[Unit]
Description=VERITAS Cluster Server (VCS)
SourcePath=/opt/VRTSvcs/bin/vcs
...
...
[Service]
...
...
...
TimeoutSec=300
[Install]
...

After you specify the custom timeout value in a unit service file, you must reload the systemd daemon so that the configuration is updated:

( root@localhost-vm1 )[ ~ ] # systemctl --system
 daemon-reload

Then, start or stop the unit service file:

( root@localhost-vm1 )[ ~ ] # systemctl start vcs