Solaris · Process Management

Solaris · Lesson 10

Process Management

Monitor processes using ps and prstat. Kill and priority handling. Troubleshoot high CPU usage. Real production scenarios.

Why process management is important

Processes are the running programs on your Solaris system. As an administrator, you must be able to see what is running, identify heavy processes and clean up hung ones without destabilising the server.

In this lesson, we focus on core process tools that you will use almost daily: ps, prstat, pgrep, pkill, kill and renice.

Key concepts in process management

Processes & PIDs

Every running program is a process with a unique Process ID (PID). Parent/child relationships help you understand who started what.

Load & resource usage

Tools like prstat show you which processes are consuming CPU and memory so you can quickly spot bottlenecks.

Signals & control

Commands like kill, pkill and nice let you send signals to processes to stop, reload or change their priorities.

Step-by-step process commands

Run each of these command sequences in your Solaris lab VM. Observe how the output changes when you start or stop applications in another terminal.

1. List all processes with ps -ef

ps -ef shows a snapshot of all running processes with their PIDs, parents, and commands.

terminal — processes
solaris-lab
[root@solaris ~]# ps -ef | head
UID PID PPID C STIME TTY TIME CMD
root 0 0 0 Jan 10 ? 0:03 sched
root 1 0 0 Jan 10 ? 0:05 /sbin/init
root 2 0 0 Jan 10 ? 0:00 pageout
root 3 0 0 Jan 10 ? 0:00 fsflush
root 123 1 0 Jan 10 ? 0:02 /usr/lib/ssh/sshd
root 256 1 0 Jan 10 ? 0:01 /usr/sbin/svc.startd
root 890 123 0 Jan 11 ? 0:00 sshd: oracle@pts/1
oracle 891 890 0 Jan 11 pts/1 0:00 -bash
root 1200 1 0 Jan 11 ? 0:00 /usr/sbin/cron
 
[root@solaris ~]# ps -ef | grep sshd
root 123 1 0 Jan 10 ? 0:02 /usr/lib/ssh/sshd
oracle 890 123 0 Jan 11 ? 0:00 sshd: oracle@pts/1
root 1340 1200 0 Jan 11 pts/2 0:00 grep sshd

2. Monitor resource usage with prstat

prstat is like top on Solaris. It shows CPU and memory usage for processes in real time.

terminal — processes
solaris-lab
[root@solaris ~]# prstat 1 5
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP
891 oracle 120M 40M sleep 59 0 0:00:02 1.0% bash/1
950 root 150M 60M sleep 59 0 0:00:05 0.5% java/35
123 root 60M 20M sleep 59 0 0:00:02 0.2% sshd/1
1 root 30M 10M sleep 59 0 0:00:05 0.1% init/1
...
 
Total: 45 processes, 125 lwps, load averages: 0.24, 0.20, 0.14

3. Find and signal processes using pgrep and pkill

Use pgrep to find PIDs by name and pkill to send signals. This is safer than grepping ps output manually.

terminal — processes
solaris-lab
[root@solaris ~]# pgrep -fl sshd
123 /usr/lib/ssh/sshd
890 sshd: oracle@pts/1
 
[root@solaris ~]# pkill -HUP sshd
# Sends SIGHUP to all sshd processes (reload configuration).
 
[root@solaris ~]# pgrep -fl appserver
1024 /usr/local/bin/appserver --config /etc/appserver.conf

4. Terminate a hung process with kill

Always try a gentle signal (TERM) before using KILL. Confirm the PID carefully.

terminal — processes
solaris-lab
[root@solaris ~]# pgrep -fl appserver
1024 /usr/local/bin/appserver --config /etc/appserver.conf
 
[root@solaris ~]# kill 1024
# Wait a few seconds and check again:
[root@solaris ~]# ps -p 1024 -o pid,comm
PID COMMAND
1024 appserver
 
[root@solaris ~]# kill -9 1024
[root@solaris ~]# ps -p 1024 -o pid,comm
PID COMMAND
# (no output, process is gone)

5. Adjust process priority with nice and renice

nice and renice change process scheduling priority. Higher nice value means lower priority (more friendly to others).

terminal — processes
solaris-lab
[root@solaris ~]# nice -n 10 /usr/local/bin/report-job &
[1] 1500
 
[root@solaris ~]# ps -o pid,ni,comm -p 1500
PID NI COMMAND
1500 10 report-job
 
[root@solaris ~]# renice -n 5 -p 1500
1500: old priority 10, new priority 5
 
[root@solaris ~]# ps -o pid,ni,comm -p 1500
PID NI COMMAND
1500 5 report-job

Good practices for managing processes

Observation before action

  • Use ps and prstat to understand the situation before killing anything.
  • Check parent PIDs; killing a parent can also affect many child processes.
  • If a process misbehaves repeatedly, investigate logs and configuration instead of just killing it every time.

Safe use of signals

  • Prefer a normal TERM signal first (kill PID) and only use KILL (kill -9 PID) as a last resort.
  • Avoid using pkill with very generic patterns that might match more processes than expected.
  • On systems with SMF-managed services, consider using svcadm to restart services instead of killing daemons directly.

Practice task – observe and control processes

  • Open a few terminals and start simple commands (ping, sleep, loops) and watch them using ps -ef and prstat.
  • Use pgrep and pkill to find and stop your test processes by name.
  • Start a test script with nice and change its priority using renice, then observe the effect in prstat.
  • Note down a small checklist you will follow before killing a process on a real production system.

In the next lessons on service management and monitoring, you will see how process-level information combines with SMF and system logs for full troubleshooting.