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.
Before you begin
About this task
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
.Procedure
- Create a service script that includes the following parameters:Your script might look like this example:
Table 1. Systemd 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. ; 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
- Optional:
Set the agent service to autostart after startup.
For example, if you named the script ucdagent, run the following command:
systemctl enable ucdagent
Results
ps -ef | grep installFolder
For the
installFolder
variable, specify the installation folder of the
agent, such as /opt/ucd/agent
.