ps l


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ps l
# 1  
Old 11-20-2002
ps l

Hi

When I kick off a script I then need to check whether or not it is running (in another sesssion) by another script.

ps -fu$USER | grep scriptname.sh | grep -v grep |wc -l

Most of the time it is ok but if you run above command immediately after kicking off the script then you can get more than one process returned. Why is that ?

Think of changing command above to use ps l command but do not understand what the first column represents. It is F for field but I do not understand how to understand the results in the F column.
ie what does 200001 mean

Any help much appreciated.
Cheers
mphartley
# 2  
Old 11-20-2002
If you get multiple processes then your script (or more accurately, the shell running it) must have forked for some reason. Without seeing the script there is no way to be more specific.

You will need to do a "man ps" to see what the F field means on your system. It is "Flags", that is, some bits that are turned on or off. Which flags and what meaning they have varies from system to system. And as is customary here, you did not reveal which system you are using. Most people just ignore that field these days. For example, on HP-UX, one bit means "locked in core". The trouble is that these days a process is not a monolith but rather a collection of regions. If one region is locked, do you set the bit? Another example, one bit means "in-core". How can that bit have any meaning at all in a demand-paged environment? Those flags were invented in a simpler time.
# 3  
Old 11-20-2002
Save a process

Quote:
Originally posted by mphartley
When I kick off a script I then need to check whether or not it is running (in another sesssion) by another script.

ps -fu$USER | grep scriptname.sh | grep -v grep |wc -l
As Perderabo noted separately, your shell probably forked.

Another hint: You can save a process --- and time unless $USER has thousands of processes running but maybe even then --- this way (idea from Essential System Administration by Aeleen Frisch, 2nd edition, but I think a 3rd is out now):
Code:
ps -fu$USER | grep '[s]criptname.sh' |wc -l

Why this works is left as an exercise for the reader ... Smilie
# 4  
Old 11-20-2002
Thanks for this

My process is forking. I will look that up.

My OS is an IBM RS6000 AIX4.3

I have actually got the manuals which are a replication of 'man' and have spent several hours trawling this.

The F field flags it gives in the book make no sense to me eg

SLOAD 0x00000001 Indicates that the process is operating in core memory.

But when I do a ps l I get

240001 A 219 15202 14454 0 60 20 b61e 504 584 EVENT pts/3 0:00 -ks

So do not understand how I translate the above 240001 into a meaningful message.
Thx
MH
mphartley
 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question