Here's my Systemd script:
[Unit]
Description=RDS Services
[Service]
WorkingDirectory=/home/rdsdb2/script_rds/
Type=oneshot
ExecStart=/bin/bash start_services.sh
ExecStop=/bin/bash stop_services.sh
KillMode=process
[Install]
WantedBy=multi-user.target
I can't figure out why it executes sequentially (at system start or when i start it manually) ExecStart and ExecStop.
Can you help me?
Thanks in advance.
The ExecStop setting is optional and is used to communicate with the service for a clean termination. The process specified by ExecStop will run in case the service crashes.
ExecStart. The command to run to start the service. This includes the full path to the command and arguments to modify the service. The resulting [Service] section looks like this: [Service] Type=simple ExecStart=/usr/bin/sleep infinity.
Control whether the service starts with the system You can use the enable and disable subcommands to manage those defaults. Reboot the system with reboot sudo systemctl reboot , and the service won't automatically start.
systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, maintains mount and automount points, and implements an elaborate transactional dependency-based service control ...
Type=oneshot
is used for units, such as a filesystem check or a cleanup, which execute an action without keeping active processes. Such systemd units will wait until the process specified by ExecStart
terminates, and then deactivate by running the process specified by ExecStop
.
Type=simple
(the default setting) is used when the process configured with ExecStart
is the main process of the service. Such units will wait until the process specified by ExecStart
returns, then deactivate by running the process specified by ExecStop
.
With RemainAfterExit=yes
, the service will be considered active even when all its processes have returned, and therefore the process specified by ExecStop
will not run automatically. However, this setting is not recommended since the service will still appear as being active even if it has crashed. This setting is disabled by default.
Type=forking
is used when the process specified by ExecStart
is expected to exit after start-up is complete, while its child process(es) continue(s) to run in the background. This is the behavior of traditional UNIX daemons and the recommended choice in your case. The ExecStop
setting is optional and is used to communicate with the service for a clean termination. The process specified by ExecStop
will run in case the service crashes. In the absence of any ExecStop
option, the systemctl stop servicename
command will simply kill the remaining processes of the unit, as specified by the KillMode
option.
if you run
[Service]
Type=simple
than you need: RemainAfterExit=yes
OR use forking:
[Service]
Type=forking
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With