Site icon UnixArena

Solaris Process controlling – proc tools

In the last post, we have seen about process status using prstat.But here we are going to see how to control the process using pid in Solaris  Many of the Solaris administrator may thinking  how to freeze the process ? Some beginners may still have doubt that how to kill the process? Some of them may still wondering how start the stopped process. 
Here we have the answer for all the above questions. 
Process controlling tools 
We can control the process using the below commands.

table.tableizer-table { border: 1px solid #CCC; font-family: ; font-size: 12px; } .tableizer-table td { padding: 4px; margin: 3px; border: 1px solid #ccc; } .tableizer-table th { background-color: #104E8B; color: #FFF; font-weight: bold; }

Listing and controlling process
PTOOLS DESCRIPTION
ptree To print a process origin tree of the system
pkill To kill the process using pid or using pgrep
pgrep To match a process name from process list
prun To continue a process specific process
pstop To freeze a process specific process
pwait To wait for a process to finish
preap To reap zombies i.e to clear the zombie process

Here i will just show you the putty terminal output of each commands.
ptree:
Using ptree command you can see where that process has been started and you can see its origin. 
# ptree 3222
2141 /sbin/sh - /usr/lib/vxvm/bin/vxcached root
3222 /sbin/sh - /usr/lib/vxvm/bin/vxcached root
3223 vxnotify -C -w 15
#


pkill:
Using pkill command you can kill the process using process id (pid). This is just alternative of “kill -9 pid”

# ps -ef |grep find
root 10881 4080 7 22:52:05 pts/3 0:04 find / -name test
root 10886 4080 0 22:52:22 pts/3 0:00 grep find
# kill -9 10881


pgrep:
using pgrep command,you can filter the process using certain criteria.

# pgrep sshd
1814
15250
4068
4069
Verifying our work using below command
# ps -ef |egrep "1814|15250|4068|4069"
root 1814 1 0 May 06 ? 0:01 /usr/lib/ssh/sshd
root 4076 4069 0 18:18:19 pts/3 0:00 -sh
root 15250 1 0 02:08:11 ? 0:00 /usr/lib/ssh/sshd
root 4068 1814 0 18:18:13 ? 0:00 /usr/lib/ssh/sshd
root 4069 4068 0 18:18:13 ? 0:03 /usr/lib/ssh/sshd
#


pstop:
You can suspend the process temporarily using pstop command.This will just freeze the process unless untill you start it again.

# ps -ef |grep find
root 11162 4080 4 23:02:18 pts/3 0:02 find / -name test
root 11164 4080 0 23:02:31 pts/3 0:00 grep find
# pstop 11162
# prstat
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
11162 root 1656K 1048K stop 60 0 0:00:47 27% find/1


prun:
The prun command used to start the process which was stopped by pstop command.

# prun 11162
# prstat
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
11162 root 1656K 1048K cpu0 53 0 0:00:22 20% find/1


pwait:
The pwait command just blocks and waits for termination of a process in Solaris.

# pwait 11162


preap:
Using preap,you can just get rid of zombie process aka defunct process
Please see the link to know more about preap.

Hope you have learned more about Solaris process controlling.

Thank you for reading the article. Please leave a comment if you have any doubt. 

Exit mobile version