0

Dear friends and colleges ,

We have service under /etc/systemd/system

Service name is calc_live_servers.service

Since Restart=always is configured in calc_live_servers.service

Then when we kill the PID of the process or kill -9 , then service is restarted again and will be up

is it possible to kill the PID so service will not start again after we kill it in spite Restart=always?

The service calc_live_servers.service

[Unit]
Description=calc_servers Server
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
LimitMEMLOCK=infinity
LimitNOFILE=65535
Type=simple
User=CAS
Group=CAS
ExecStart=/usr/bin/calc_servers-start /etc/calc_servers/calc_servers.properties
ExecStop=/usr/bin/calc_servers-stop
Restart=always

[Install]
WantedBy=multi-user.target

Main target - is to stop the service by kill the PID without use systemctl stop <SERVICE NAME > and that because sometimes stopping the service not really stop it

2

Instead of killing PID, stop the service with sudo systemctl stop calc_live_servers - that is the way to stop a service. And if you don't want to have it running, disable the service with sudo systemctl disable calc_live_servers.

4
  • but as I said sometimes service not stopped , so this is the reason that we want to kill the PIS but after we kill it then service start again because Restart=always – user436442 Nov 10 '20 at 10:28
  • Stop and kill then. – Artem S. Tashkinov Nov 10 '20 at 10:44
  • no so good in some case when I stop the service then pid will also killed before I killed it with kill command – user436442 Nov 10 '20 at 11:17
  • you could killall process_name or ps ax | grep process_name OR pgrep process_name to find its PID. – Artem S. Tashkinov Nov 10 '20 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy