LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   view running deamon ps -p (https://www.linuxquestions.org/questions/linux-newbie-8/view-running-deamon-ps-p-4175639901/)

fick_manning 10-07-2018 11:37 AM

view running deamon ps -p
 
1 Attachment(s)
hay guys
i am in a red hat course and in need to check if deamons that belongs to a service (chronyd)are running.
in the book they do it by ps -p PID
but when i do this i get this output:
Attachment 28749
as you can see i dont get nothing.
why is that and how i can verifay that the deamon is running?

average_user 10-07-2018 12:10 PM

The last line 'ps -p 675' shows chronyd, what's the problem?

fick_manning 10-07-2018 12:27 PM

the assigment is that i need to verifay that that those deamons are running
but i dont understand the output - it is just headlines...
it dosent tell me if it is running or not

average_user 10-07-2018 12:45 PM

It does. Read 'man ps':
Code:

-p pidlist
  Select by PID.  This selects the processes whose process ID numbers appear in pidlist.  Identical to p and --pid.

When you pass a wrong PID process name is not shown and $? is set to non-zero. Try this:
Code:

$ ps -p 9999
  PID TTY          TIME CMD
$ echo $?
1
$ ps -p 1
  PID TTY          TIME CMD
    1 ?        00:00:21 init
$ echo $?
0


fick_manning 10-07-2018 01:06 PM

first of all tnx for the help!!
so.. in my example under all of them theres is nothing excpet for the main PID and even then theres is a "?" under tty.
unlike youre example that there is time and in my example the time is 00:00 and in yours there is time that have past...
i am passing the pid's from the the command "systemctl status chronyd" whic are:
728
661
and the main PID: 675

average_user 10-07-2018 02:49 PM

In your screenshot you use incorrect PIDs 728 and 661 - there are no processes that have such PIDs on your system. In my example above I've used 9999 as a fake PID to represent the situation. Notice that my version of ps acts identically to yours and only prints header when non-existent PID is given and sets $? to non-zero.

fick_manning 10-07-2018 03:35 PM

Quote:

Originally Posted by average_user (Post 5912120)
In your screenshot you use incorrect PIDs 728 and 661 - there are no processes that have such PIDs on your system. In my example above I've used 9999 as a fake PID to represent the situation. Notice that my version of ps acts identically to yours and only prints header when non-existent PID is given and sets $? to non-zero.

tnx man!

fick_manning 10-07-2018 05:46 PM

1 Attachment(s)
but than why are "728","661" cant be procces number? this is what i dont understand...
like in these blue box in i draw in the pic below (which you talked about erliar)
Attachment 28752
i mean - 728 661 - why cant it be a processes if that's what the command return (again in the blue box i draw)
i can use the 675 like on "ps -p 675" then why not "ps -p 661/728" ?
the systemctl command show those numbers as proccess

scasey 10-07-2018 05:57 PM

Quote:

Originally Posted by fick_manning (Post 5912168)
but than why are "728","661" cant be procces number? this is what i dont understand...
like in these blue box in i draw in the pic below (which you talked about erliar)
Attachment 28752
i mean - 728 661 - why cant it be a processes if that's what the command return (again in the blue box i draw)
i can use the 675 like on "ps -p 675" then why not "ps -p 661/728" ?
the systemctl command show those numbers as proccess

Those processes have already ended. The only one continuing to run (the daemon) is 675

MadeInGermany 10-09-2018 09:57 PM

Perhaps 728 661 are threads (LWPs)?
Check the main PID for its threads
Code:

ps -fLp 675
Linux takes both processes and threads from the PID pool.

average_user 10-10-2018 09:12 AM

I don't think so. Notice ExecStart - these processes probably died after doing exec(). It looks like 661 change to 675.


All times are GMT -5. The time now is 10:40 AM.