How retrieve Process status (up/down)

How to retrieve Process status (on a Linux vm), having the program name
and some parameter. I saw that you should be able to do that when you know the PID, but I need
to do it from a name and parameter.

Some directions would already be fine.


what about “ps aux” getting the line of this process (or not if it is not running)?

On Unix, the PID is what’s used as the unique identifier for each process. Starting from that, you can get information about the process.

Linux systems have a /proc filesystem that contains information about processes. A directory listing for /proc will show many directories named by numbers, and each is a PID. Within those directories there are files with various information available, including

/proc/<PID>/comm – the name of the command
/proc/<PID>/cmdline – the command line, including arguments

You can search through those to find which PID has the command name/arguments you are interested in.

See the manual page for proc(5) for details:

To check your code, you can use

pidof <command_name>

which prints PIDs of commands with the given name.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.