LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-17-2018, 08:24 AM   #1
tankzeu
LQ Newbie
 
Registered: Sep 2018
Posts: 26

Rep: Reputation: Disabled
Deleting systemd pid file


While systemd service is running,I have deleted the pid file however "systemctl status <service_name>" shows that the service is still running while it is not,are there any other harms apart from not seeing the actual status?
 
Old 10-17-2018, 08:30 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: FreeBSD/Slackware-14.2+/ArcoLinux
Posts: 9,067

Rep: Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900
why didn't you use systemctl to shut down the service?
I do not see why it would harm anything other than if something calls for it, as it seems to be showing it is still running, then you'll get an error from that program that called it perhaps logging, or sending a mess to stdout to what happened. Worse case scenario it fails and locks up your system to where you need to reboot it. but that can happen to anyone for a number of reasons.

Last edited by BW-userx; 10-17-2018 at 08:31 AM.
 
Old 10-17-2018, 08:36 AM   #3
tankzeu
LQ Newbie
 
Registered: Sep 2018
Posts: 26

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by BW-userx View Post
why didn't you use systemctl to shut down the service?
I do not see why it would harm anything other than if something calls for it, as it seems to be showing it is still running, then you'll get an error from that program that called it perhaps logging, or sending a mess to stdout to what happened. Worse case scenario it fails and locks up your system to where you need to reboot it. but that can happen to anyone for a number of reasons.
The thing is I have this old script which worked by far correctly deleting the pid file of init.d service,however now the service is systemd , so I am wondering will this script have any bigger harm than showing not correct status and some error msg in the console?
 
Old 10-17-2018, 09:07 AM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: FreeBSD/Slackware-14.2+/ArcoLinux
Posts: 9,067

Rep: Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900
Quote:
Originally Posted by tankzeu View Post
The thing is I have this old script which worked by far correctly deleting the pid file of init.d service,however now the service is systemd , so I am wondering will this script have any bigger harm than showing not correct status and some error msg in the console?
transgressing from systenV to systemD or whatever init to systemD
that is my logical guess that I gave you as even I now that I've migrated over to other distros using systemD and do not pay much attention to it. other than having to fix my time (clock) to local time using systemD.

SO what I said was just a logical assumption using processes. if you delete the pid file what takes place, it might not get updated within the system, but it is not being used for anything, so how can it be harmful to the system only because the 'log' was not updated and it thinks it is still being used.

therefore only if something called to it thinking it is still in effect because the system says it is, then an error will , or should occur, yes?

otherwise I do not see how it could harm anything other then if you tried using it again and the app checks first by the use of what the system says and not checking to see if a pid file itself exist then fails on account of that. If it checks to see if a file exist first then sees that it does not. then does it give it a new pid number file or same?


even so only one file exist no matter what. does it cause a drain to the system resources by allotting memory that will not be used, and if you kill the pid file by deleting it then start it again then keep repeating this process will you drain the system of memory? theoretically, yes. if that is what occurs by deleting a pid file.


disclaimer:

me I'd run it and see, to discover the truth through experimentation, or figure out how to handle pid files using systemD.

it is your system I do not know how mission critical this is.
 
Old 10-17-2018, 02:27 PM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 12,301
Blog Entries: 9

Rep: Reputation: 3306Reputation: 3306Reputation: 3306Reputation: 3306Reputation: 3306Reputation: 3306Reputation: 3306Reputation: 3306Reputation: 3306Reputation: 3306Reputation: 3306
i'm pretty sure it will fix itself - probably after a reboot.

or you could always provide some actual information about your problem, we could give better help.
 
Old 10-17-2018, 02:36 PM   #6
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,614

Rep: Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202
Is it not true that deleting a file that is in use has no effect on the process using it?

That is, as long as the process is holding the file open, it will continue to be available to that process and only be physically removed from memory when the process ends. Am I remembering that correctly?

That said, I agree that rather than attempt to guess the effect of deleting a pid file, the OP ask/tell us what problem he's trying to solve.
 
Old 10-17-2018, 05:17 PM   #7
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: FreeBSD/Slackware-14.2+/ArcoLinux
Posts: 9,067

Rep: Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900
why would you delete it when it is in use?
 
Old 10-17-2018, 05:47 PM   #8
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,614

Rep: Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202
Quote:
Originally Posted by BW-userx View Post
why would you delete it when it is in use?
Isn't that what the OP said they were doing?
Quote:
While systemd service is running,I have deleted the pid file...
 
Old 10-17-2018, 06:14 PM   #9
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: FreeBSD/Slackware-14.2+/ArcoLinux
Posts: 9,067

Rep: Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900
Quote:
Originally Posted by scasey View Post
Isn't that what the OP said they were doing?
I interpreted it as systemD is always running if it PC is turned on, the app being separate and creating a pid file, some times they do not get deleted after shut down, that he just deleted it and check it said the app pid still being registered/ running. you might be more right then me, as now typing this out it does not sound logical to show it in process if it is no longer running, but It's system d.
 
Old 10-17-2018, 06:51 PM   #10
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,614

Rep: Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202Reputation: 1202
An example I've seen is having a program writing to (or even reading from) a file, and while it was running deleting the file. That has no effect on the program; it continues to run...it continues to have access to the file.

So what I'm suggesting is that deleting the pid file of a systemd process would not terminate the process, and the systemctl status indicating it still running is not a false report...the process would still be running.

I still think we still need a clarification from the OP about why they are deleting a pid file.
 
Old 10-17-2018, 06:58 PM   #11
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: FreeBSD/Slackware-14.2+/ArcoLinux
Posts: 9,067

Rep: Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900Reputation: 1900
agree, as I have had left over pid files and when trying to start again, it says no because of the file, so I just delete it manually.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Stopping systemd by killing it's pid tankzeu Linux - Newbie 3 10-19-2018 12:24 PM
how to kill PID based from pid file contents apss_evaluator Linux - Newbie 4 07-30-2015 08:07 AM
Confluence PID issue. (Removing/clearing stale PID file) vignesh4sh Linux - Server 5 12-05-2012 07:14 AM
[SOLVED] squid - incorrect pid in pid file theIndividualist Linux - Software 2 05-31-2012 08:23 AM
ERROR: Couldn't write pid to pid file lawrencegoodman Linux - Newbie 2 02-13-2004 08:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:44 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration