LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-24-2024, 10:04 AM   #1
cormanstnl
Member
 
Registered: Jul 2007
Posts: 60

Rep: Reputation: 0
Question systemctl kill pgm to fast


Hi,

I have a java pgm running on a server.
I made a bash script for start the java and an other to stop the programme.

And a call these scripts from a systemd script.

Code:
[Unit]
Description=PONTBASCULEDP
After=mysqld.service

[Service]
Type=oneshot
ExecStart=/opt/middleware/pontbasculedp/start_robot_pontbasculedp.sh
ExecStop=/opt/middleware/pontbasculedp/stop_robot_pontbasculedp.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
The command for ending the program consist to put a value "STOP" on a table and a thread check if the "STOP" is set and if yes, end thread and exist the application.

But when the call of stop_robot_pontbasculedp.sh is executed by systemd, I see that the flag for stopping the pgm is set but systemctl send the SGIKILL or SIFTERM to fast and the process is killed and not ended correctly.

So how to add a wait or somethings like this for ask systemd to wait the end of the program ?
 
Old 04-24-2024, 10:18 AM   #2
lvm_
Member
 
Registered: Jul 2020
Posts: 942

Rep: Reputation: 338Reputation: 338Reputation: 338Reputation: 338
Systemd requires ExecStop process to be synchronous, it should not exit until all service process have terminated. If it does systemd immediately kills whatever is left running. Make the stop script wait the proper way or just add 'sleep 10' to it.
 
1 members found this post helpful.
Old 04-24-2024, 10:24 AM   #3
cormanstnl
Member
 
Registered: Jul 2007
Posts: 60

Original Poster
Rep: Reputation: 0
Lightbulb

Thank you for the idea ... It's working...
I added sleep 30 on my stop script
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Systemctl Mask vs Systemctl Disable LXer Syndicated Linux News 0 01-17-2024 01:40 PM
[SOLVED] Welcome to emergency mode! After logging in, type "journalctl -xb" to view system logs, "systemctl reboot" to reboot, "systemctl default" or grounddolphin Linux - Newbie 11 06-09-2023 05:34 PM
systemctl rescue does not kill interactive shells? berndbausch Linux - Server 2 05-02-2020 09:19 PM
Restart systemctl*daemon​ - systemctl command not found cjosephl Linux - Newbie 7 11-11-2017 04:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration