ยง2023-08-31
If you like to tell a process is finished at remote, for eample make -j4
[alexlai@hc4Gentoo ~]$ pgrep make
254964
256241
277470
293392
343125
344810
345280
347758
[alexlai@hc4Gentoo ~]$ ps 254964
PID TTY STAT TIME COMMAND
254964 tty1 S+ 0:00 make -j4
In the output you provided, the STAT column displays the status of the process. In this case, the status is S+. Here's what it means:
- S: The process is in the "interruptible sleep" state. This means the process is waiting for an event to complete, such as I/O (Input/Output) operations or a signal from another process.
- +: The process is in the foreground process group. This means it is associated with the terminal and can receive user input.
The combination of S and + indicates that the process is currently waiting for an event to complete and is also associated with the terminal. In this case, it seems that the make process (PID 254964) is still actively running and waiting for something, possibly I/O operations or other subprocesses to complete.
SO, if I can not get anyhting from
ps 254964
then it is done. ChatGPT
- Yes, that's correct. If you run the ps command with a specific PID, like ps 254964, and you don't get any output, it means that the process with that PID is no longer running. In other words, if the process has finished, it won't show up in the list of currently running processes when using the ps command with its PID. This can be a good way to confirm that the process has completed its execution.
[alexlai@hc4Gentoo ~]$ ps 256241
PID TTY STAT TIME COMMAND
256241 tty1 S+ 0:00 make -f ./scripts/Makefile.build obj=. need-builtin=1 need-modorder=1
[alexlai@hc4Gentoo ~]$ ps -o ppid= -p 256241
254964
[alexlai@hc4Gentoo ~]$ ps -o ppid= -p 277470
256241
[alexlai@hc4Gentoo ~]$ ps -o ppid= -p 293392
256241
[alexlai@hc4Gentoo ~]$ ps -o ppid= -p 343125
277470
[alexlai@hc4Gentoo ~]$ ps -o ppid= -p 344810
[alexlai@hc4Gentoo ~]$ ps -o ppid= -p 345280
[alexlai@hc4Gentoo ~]$ ps -o ppid= -p 347758
[alexlai@hc4Gentoo ~]$ ps 254964
PID TTY STAT TIME COMMAND
254964 tty1 S+ 0:00 make -j4
[alexlai@hc4Gentoo ~]$ ps 347758 <-- finished
PID TTY STAT TIME COMMAND