Home Man
Search
Today's Posts
Register

If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Ps command

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 10-11-2017
Ps command

Hi,
I'm trying to learn Unix and I've yet the first problems on a basic command like ps.

If I have 2 different parameters, one more "restrictive" than the other, which of those controls? Let me explain:
-a: Select all processes except both session leaders and processes not associated with a terminal.
-d: Select all processes except session leaders.
If I use ps -ad is the same thing that use ps -da? If the more "restrictive is a, is the d parameter superfluous?

a command like ps -edaf what processes will show?

Thank you!

Last edited by rbatte1; 10-12-2017 at 09:09 AM.. Reason: ICODE tags for clarity
# 2  
Old 10-11-2017
Quote:
Originally Posted by dummyx
Hi,
I'm trying to learn Unix and I've yet the first problems on a basic command like ps.

If I have 2 different parameters, one more "restrictive" than the other, which of those controls? Let me explain:
-a: Select all processes except both session leaders and processes not associated with a terminal.
-d: Select all processes except session leaders.
If I use ps -ad is the same thing that use ps -da? If the more "restrictive is a, is the d parameter superfluous?

a command like ps -edaf what processes will show?

Thank you!
Assuming you have access to a Unix or Linux machine, why not try all combinations and find out? Assuming the output is one process listed per line you could pipe the output of ps into wc -l just to see how long each listing would be. Then you can draw your own conclusions.

Andrew

Last edited by rbatte1; 10-12-2017 at 09:10 AM.. Reason: Retro-fit ICODE tags into quoted post
# 3  
Old 10-11-2017
I tried, but I didn't understand.
I tried, for example, ps -e, then ps -ed and the list was shorter than the first. So I thought it was depending on the d parameter, more restrictive, but I tried ps -d and the list was shorter again, so the -d parameter alone was more restrictive...
I tried other combinations, but had the same, confusing, results...

Last edited by rbatte1; 10-12-2017 at 09:11 AM..
# 4  
Old 10-11-2017
Our shop has ps -ef in a number of scripts--does that work?

Last edited by rbatte1; 10-12-2017 at 09:11 AM.. Reason: Added ICODE tags
# 5  
Old 10-11-2017
The result of conflicting options depends on the ps version and should be documented in man ps.
The order of options should never matter, ps -ad is indentical with ps -da.
Please note that if you compare ps -e then ps -ed on an active system then it can differ because the number of processes have changed in between.
# 6  
Old 10-11-2017
Quote:
Originally Posted by MadeInGermany
The result of conflicting options depends on the ps version and should be documented in man ps.
The order of options should never matter, ps -ad is indentical with ps -da.
Please note that if you compare ps -e then ps -ed on an active system then it can differ because the number of processes have changed in between.
Thanks. So instead of using ps -ed I'd use ps -d obtaining the same result, correct?

Last edited by rbatte1; 10-12-2017 at 09:12 AM.. Reason: Added ICODE tags for clarity
# 7  
Old 10-11-2017
No, -e and -d conflict, so consult your man page or try it out on the command line.
And if you try it out, be aware that the number of processes on the system can change any time. Even your ps command makes a process, and there is a race condition: the process table can be listed *before* or *after* the ps process appears in it.
(Tools like pgrep or pidof are safer, they take care to not list themselves.)
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Execute ssh command with additional terminal command to any remote user not working script tomislav91 Shell Programming and Scripting 8 02-26-2018 09:13 PM
Command to check only Autosys running jobs with autorep like command sidnow Shell Programming and Scripting 0 11-04-2014 09:03 PM
SH script, variable built command fails, but works at command line oly_r Shell Programming and Scripting 8 09-14-2012 05:56 PM
passing command output from one command to the next command in cshell kaaliakahn UNIX for Dummies Questions & Answers 2 02-10-2012 04:59 PM
unix command : how to insert text at the cursor location via command line? xib.be UNIX for Advanced & Expert Users 0 12-22-2010 05:45 PM
Need help! command working ok when executed in command line, but fails when run inside a script! 4dirk1 Shell Programming and Scripting 4 12-02-2010 05:47 AM
awk command in script gives error while same awk command at prompt runs fine: Why? catalys Shell Programming and Scripting 4 09-20-2010 10:07 PM
awk/sed Command : Parse parameter file / send the lines to the ksh export command rajan_san Shell Programming and Scripting 4 11-06-2008 12:29 PM
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 08:12 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl SuSE 5 07-30-2007 08:26 AM


All times are GMT -4. The time now is 12:20 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password