![]() ![]() 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. 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. 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. 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 $$ 1 Answer Sorted by: 2 Let's suppose a process certb is currently running. The -h option is to remove the header line. This will probably produce a lot of output in your terminal. x list processes that don’t belong to any tty. 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. u display user oriented format (displays additional information about running processes). ![]() A single MatchInfo object will still be emitted for each line, but it will contain all of the matches found. Something as simple as ps -h $$ > catch will probably do it. Parameters of Select-String AllMatches Normally, Select-String will only look for the first match in each line, using this parameter the cmdlet will search for more than one match. then - filter down using grep to a single process, which you had in step 1.plus - all other process that don't have a tty too (x option).plus - all other processes which have a tty (a option). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |