differentiating PIDs under 200


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting differentiating PIDs under 200
# 1  
Old 03-16-2010
differentiating PIDs under 200

Hey,

So I'm new to shell scripting, and I'm trying to write one for my lab that will keep down the work load by deleting processes that are left over from previous sessions.

Basically I want it to do three things.

1) Check the processes running
2) See if that person is logged on.
3) if not, delete the process.

I've got a pretty good idea about how to do all that, but I need it to ignore all of the root and system processes that run all the time. All of those have a PID under 200 so how do I say

"For processes with PID over 200" or possibly "Show only processes with PID over 200"? I could also do between 200-10000.

I tried 'seq 200 10000', but I think it's too big of a range, and it won't work.




then the next step I'm using is

ps auxw |cut -f1 -d\ |sort -u > $OUTPUTLOC/ScriptDraft.proc$$

(where OUTPUTLOC = /tmp)

Any help is greatly appreciated.
# 2  
Old 03-16-2010
Looking for process based on pid ranges is not a good idea. What I suggest is to identify the processes based on its name/script name.

However for the question you asked, here is the answer

Code:
ps -ef | awk '$2 >200 && $2<10000'

# 3  
Old 03-16-2010
I might suggest that you approach this differently.

If the user is logged out, there will be no tty listed in ps - it will be a question mark.

Secondly - hanging processes like this are almost always some badly written app - don't you already know what the process name is??



Another often useful clue for these things is that they sometimes accumulate much more CPU time than would be normal (again, badly written to start with and they go insane when disconnected from their pty).
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get all associated pids

im looking for a portable way to get the PID of the script that is running, and to get every other PIDs that are spawned from it. and by ever other PIDs, i presume, that would be "child processes". however, i want to shy away from using any command that is not available on every single unix... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

Merging and differentiating 2 files

I have 2 csv files say file1 and file2. Based on 2 columns, I want to check if the values of file1 is present in file 2 or not. If it's not present then it should create a file with the values which are not present. Basically I want the minus between 2 files but based on 2 columns but the output... (2 Replies)
Discussion started by: Gangadhar Reddy
2 Replies

3. Shell Programming and Scripting

Need help to kill pids

Hi there !!! I am writing a script to kill the pids on different linux boxes :cool: the output of my command gives the pids running on that box, but how can I kill all the pids without looping? :confused: Code: ssh $i ps -fu $USER | grep ManServer | grep -v grep | awk '{print $2}' | kill ... (4 Replies)
Discussion started by: prany_cool
4 Replies

4. Solaris

Conflict with PIDs

I am trying to determine the root cause of a java process that dies trying to startup during it's cron job. I did go ahead and change the time that it starts up in the cron file and now it starts successfully. However is there a way to determine what PID a process was attempting to get when... (5 Replies)
Discussion started by: vedder191
5 Replies

5. UNIX for Dummies Questions & Answers

Parameters to check while differentiating two servers

Hi All, I have two solaris servers. Please tell me what all parameters i can check to find out the difference between two servers. how to differentiate based on H/W,S/W etc like i have two servers spdwa013 $ uname -an SunOS spdwa013 5.8 Generic_117350-61 sun4u sparc SUNW,Sun-Fire-480R ... (1 Reply)
Discussion started by: usha rao
1 Replies

6. Shell Programming and Scripting

differentiating two sets for filenames????

set 1 ./abc@@/main/61 ./def.cpp@@/main/13 ./fgh.cpp@@/main/16 ./ijk.cpp@@/main/12 ./mln.cpp@@/main/9 ./uvw.cpp@@/main/30 set2 ./eww@@/main/61 ./def.cpp@@/main/13 ./xxx.cpp@@/main/26 ./kkk.cpp@@/main/72 ./qqq.cpp@@/main/19 ./fgh.cpp@@/main/16 I have two sets with filenames in... (13 Replies)
Discussion started by: skyineyes
13 Replies

7. Shell Programming and Scripting

differentiating two sets

Hi Suppose i have a set of files like this set1 a.cpp@@main/5 b.cpp@@main/6 set 2 m.cpp@@main/51 n.hpp@@main/51 a.cpp@@main/15 b.cpp@@main/2 there may be files with same name in 2 sets. i need to list the files in set1 which have last numeric field less than the same file in... (15 Replies)
Discussion started by: skyineyes
15 Replies

8. Shell Programming and Scripting

Comparing PIDs in a Shell...

Hi, There is a file having a list of running PIDs (pid_process) and another file having a list of registered PIDs (pid_regieter). I want to check if:- a) there is at least one running PID that does not correspond to a registered PID (listing the PID not registered in the file) ... (1 Reply)
Discussion started by: marconi
1 Replies

9. Shell Programming and Scripting

comparing PIDs in shell..

Hi, There is a file having a list of running PIDs and another file having a list of registered PIDs. How can we check if the number of running PIDs are less or more than the registered PIDs, comparing the total no. in each and also each value. Request you to pls give your inputs. Thanks a... (2 Replies)
Discussion started by: marconi
2 Replies
Login or Register to Ask a Question