getting pid of process


 
Thread Tools Search this Thread
Operating Systems Solaris getting pid of process
# 1  
Old 03-20-2007
getting pid of process

hi all,

Is there a simple script anyone could through out to me, to find the pid of a process given the name. I actually need to bind this pid to a processor set. I would probably put these comamns in a shell script which would have.
a) kick start the executable
b) get the pid
c) bind it to a specific processor set


second question is, would anyone know a way of getting the process ID inside a java program?

PS: SORRY, I accidentally posted this in the wrong topic. Should have been under Scripting & shell.

Last edited by Naanu; 03-20-2007 at 07:54 PM..
# 2  
Old 03-21-2007
man pgrep; man pidof
# 3  
Old 03-21-2007
small test, seems to work:

Code:
root@mp-wst01 # poolcfg -c 'create pool pressy'
root@mp-wst01 # poolcfg -c 'create pset pressy-set'
root@mp-wst01 # poolcfg -c 'associate pool pressy (pset pressy-set)'
root@mp-wst01 # poolcfg -c 'modify pset pressy-set ( uint pset.min = 1 ; uint pset.max = 2 )'
root@mp-wst01 # pooladm -c
root@mp-wst01 # ps -ef | grep syslogd
    root   489     1   0   Mar 19 ?           0:02 /usr/sbin/syslogd
root@mp-wst01 # poolbind -q 489
489     pool_default
root@mp-wst01 # poolbind -p pressy -i pid `pgrep syslogd`
root@mp-wst01 # poolbind -q 489
489     pressy
root@mp-wst01 #

gP
# 4  
Old 03-21-2007
pressey..
i am not sure if it has to be done in such a complicated way, but I did it as below

id = ps -ef | grep myprocessname | grep -v grep | cut -c5-c10

psrset -b processor_set_id $id


this worked...
you can give psrset -q to see the bindings
# 5  
Old 03-21-2007
hmm, nice found.... didn't know that...

i am always working with pools to get more flexibility between the processor sets... like setting an own scheduler class for the sets or creating a "cpu-load balancing" between several sets....

btw:
short form of you 2 lines could be:
# psrset -b processor_set_id `pgrep myprocessname `

regards pressy
# 6  
Old 03-21-2007
pressy..
is there a way I could inhinit a few of my processes to go on to a particular processor_set_id?
I mean I have a box with 24virtual cpus and have created 2 processor sets.
One with 3 and the other with 20.

I want the processor set with 20 vcpus to be running uninterrupted for a particular process. I have already bound them to the process. But while they sleep, probably some other processes stell the cpus. Can I avoid it?
# 7  
Old 03-22-2007
sounds like you having fun with your 6core niagara Tx000 Smilie

but yes, and that's the reason why i am using pools.... with the solaris resource management you can start processes inside a project and that project can use a defined pool with the "project.pool" attribute and that pool is associated to a processor set... Smilie Smilie

but why don't you use zones/container? that would be the best way to isolate the processes against each other and bind the CPUs to their environment...

gP
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

How to get process name from PID?

HI, i used ps -ef | grep 3539052 | grep -v grep and i got a output like ths root 3539052 3407918 0 May 07 - 709:31 /usr/sbin/syslogd but what i need is instead of full path /usr/sbin/syslogd i want only the process name that is 'syslogd' here. (3 Replies)
Discussion started by: sumanthupar
3 Replies

2. AIX

Swapper Process #PID more than 1

Hi I would like to know more about swapper process.. I knew that swapper is the first process with PID#0, used to perform process swap operations. It used to swap entire processes But sometimes I find swapper process with PID#264 So my doubt is how many swapper process can exist in a system?... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

3. HP-UX

PID Process Resources

Hi all. I need to get detailed information about a PID. I have an app called Reflection X and it shows many things like Total CPU percent, User CPU (Nice) percent, FS Reads, etc. My question is how can I get all that information on console? Is there an archive with the detailed... (9 Replies)
Discussion started by: the0m3n
9 Replies

4. AIX

AIX: PID 0 Process

Hi All, I searched other threads and could not find any relevant post about this. I searched for process 0 in SUN OS and could find the sched/swapper process listed. root 0 0 0 Apr 25 ? 0:06 sched but i couldnt not find the swapper process (PID 0) in AIX. Is that... (4 Replies)
Discussion started by: quintet
4 Replies

5. Programming

[C] Process pid by name

Hi I use linux OS. I've already written a function that allow me to get the process name by pid. (searching in /proc). Now I'd like to perform the inverse task.I mean get the process pid by its name. I could write a function that search in every folder in /proc for the process name, but i... (2 Replies)
Discussion started by: Dedalus
2 Replies

6. Shell Programming and Scripting

getting pid from a process

Hi all, i was able to redirect pid of process to a file in the following way ps aux|awk '$11 == "/Applications/ProjectX/DServer" >> /Applications/ProjectX/DServer.pid it works fine but if one folder name caontains space its not working like below ps aux|awk '$11 == "/Applications/Project\... (1 Reply)
Discussion started by: kirankumars
1 Replies

7. Shell Programming and Scripting

Get an PID of particular process

Hi I have written a shell script to find and kill the particular process. Here in shell script i have written the code like cnt = $(ps -ef | grep Shree) echo $cnt I am getting the output root 2326 2317 0 14:39:46 pts/1 0:28 Shree -f fdc.fbconf FDCapp.fbapp Here I want to... (2 Replies)
Discussion started by: Shreedhar Naik
2 Replies

8. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

9. Shell Programming and Scripting

Process PID

Hi Friends :p I have a little problem please help me out. I have a Unix based OS Sun Server having oracle 8i as database on it. The server has one client with windows OS. The client uses developer 2000 (GUI) to run query and run processes. I want to know how can I know the PID of a process run... (3 Replies)
Discussion started by: vanand420
3 Replies

10. Programming

Child Process PID

Hi, Can anybody solve this query? A parent process forks 2 child processes. How does the child process know it's PID without the parent process sending it. Apart from the "ps-ef" option, what other options are there if any? (2 Replies)
Discussion started by: skannan
2 Replies
Login or Register to Ask a Question