Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Alternative Operating Systems > Linux: How do you get a PID and then suspend the process?

Linux: How do you get a PID and then suspend the process?
Thread Tools
Fresh-Faced Recruit
Join Date: Mar 2006
Status: Offline
Reply With Quote
Jan 21, 2009, 02:37 AM
 
I'm using RedHat Enterprise Linux. We have dozens of instances of the same program running at the same time (in a big 'at' queue). I want to be able to suspend one or several to free up CPU time for others. Unfortunately since they all carry the same process name I don't know which one is which.

The programs are launched from different directories and write to different files though. Is there any way of linking a PID to the location it was launched from or linking a PID to a file it is writing to?

And once I have the PID, is there a simple command to suspend it and free up a CPU core? Basically I'm looking for something like what ctrl-z would do for the foreground process. And how do you later continue a suspended process?
     
Posting Junkie
Join Date: Nov 2000
Location: in front of my Mac
Status: Offline
Reply With Quote
Jan 21, 2009, 03:51 AM
 
lsof will show a list of open files and the processes reading/writing to/from those files.

Do something like
code:
lsof | grep "/one/of/my/subdirectories/"

to see which process is writing to the file within that directory.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jan 21, 2009, 04:20 AM
 
You can get a list of the full paths of all running processes, their arguments and their PIDs with the following command: ps -awwx -o pid -o command

You can suspend it like control-Z with a SIGSTOP: kill -stop pid

And resume it with the corresponding SIGCONT.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Yawn  (op)
Fresh-Faced Recruit
Join Date: Mar 2006
Status: Offline
Reply With Quote
Jan 29, 2009, 11:41 AM
 
thanks for the suggestions guys.

lsof and kill -stop work like a charm
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:36 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2