Running agents as services using systemd#
Systemd is a new approach to handle services on new versions of Linux, for example, RHEL 7 or later.
Install an agent.
You can configure agents to run as systemd services by defining service scripts, for example, ucdagent.service
, ucdserver.service
, and so on. Then, place the scripts in the systemd
folder. If you are running multiple agents on the system, give the script a unique name, such as ucdagent-A.service
.
-
Create a service script that includes the following parameters:
Parameter Description HOSTNAME The host or system name where the agent or server is running. ExecStart The location of the start script in the relevant agent installation directory. Consider these examples, agent-install/bin/agent
oragent-install/bin/server
, whereagent-install
is the agent installation location.ExecStop The location of the stop script in the relevant agent installation directory. Consider these examples, agent-install/bin/agent
oragent-install/bin/server
, whereagent-install
is the agent installation location.User The name of the user who runs the agent. Group The name of the group that is associated with the user. Your script might look like this example:
```
; Define the user and group
User=wasadmin
Group=wasgrp
; Set the HOSTNAME environment variable because it is not set in systemd shell
Envionment=HOSTNAME=%H
; Call the standard vendor start and stop scripts in the relevant agent install dir
ExecStart=/usr/bin/env/opt/ibm/ucd/%i/bin/agent start
ExecStop=/usr/bin/env/opt/ibm/ucd/%i/bin/agent stop```
-
Copy the file into the
/etc/systemd/system
folder. -
Start the agent service.
For example, to run the ucdagent script, enter the following command:
systemctl start ucdagent
-
Set the agent service to autostart after startup.
For example, if you named the script ucdagent, run the following command:
systemctl enable ucdagent
The agent runs as a service. To verify that the agent is running as a service, run the following command and verify that two processes from the agent are running:
ps -ef | grep installFolder
For the installFolder
variable, specify the installation folder of the agent, such as /opt/ucd/agent
.
Parent topic: Installing agents