![]() If I'm looking for the main shell, I would generally set it to a variable first so its clear that's the one I want. 1 Answer Sorted by: 31 -e and -f are options to the ps command, and pipes take the output of one command and pass it as the input to another. Which one is correct? It depends on what you are trying to do. Scripts do this sort of thing all the time, see how the first has 3 lines but the second has only 2? This is because the first we are resolving $$ then running the script and finding out "main" shell, but the second we are doing it the other way which of course has a different PID of the child shell and doesn't match the 3802 of the parent. However, you have to be really careful of $$ in scripts because it means "this shell" but the concept of this depends on when and where it is called.Ĭonsider the two commands: $ sh -c "ps -ax | grep $$"ģ658110 pts/0 S+ 0:00 sh -c ps -ax | grep 3802ģ658142 pts/0 S+ 0:00 sh -c ps -ax | grep $$ The -h option is to remove the header line. ps takes the PIDs of the processes you are interested in as command line options so if you know what you want, specify it directly, rather than hope the grep will work. Something as simple as ps -h $$ > catch will probably do it. In this tutorial, we’ll explore how to combine the two commands to find desired processes and preserve the header line of ps ‘s output. Also, the grep command is good at filtering text. then - filter down using grep to a single process, which you had in step 1 Overview We know that the ps command is a handy utility for listing the currently running processes on the system.plus - all other process that don't have a tty too (x option).The moment you run the command, there will be two such processes: the process certb itself and the process grep certb. When you now run ps -ef grep certb you get a list of processes that contain the text certb somewhere. ![]() ![]() plus - all other processes which have a tty (a option) 1 Answer Sorted by: 2 Let's suppose a process certb is currently running. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |