Hostxpeed
Login Get Started →
Getting Started

How to Kill a Frozen Process

5 min read
27 views
Jun 12, 2026

Prerequisites

Before killing a process, make sure you have:

  • SSH access to your VPS
  • Root or sudo privileges
  • The Process ID (PID) of the frozen application

⚠️ Warning: Killing system processes can crash your server. Only kill processes you recognize as problematic.

Step 1: Identify the Frozen Process

First, find the Process ID (PID):

top

Or:

ps aux | grep "process-name"

Example - find a frozen Apache process:

ps aux | grep apache2

The second column is the PID (e.g., 12345).

Method 1: Using kill (Gentle Termination)

Send SIGTERM signal (default) - allows process to clean up:

kill PID

Example:

kill 12345

With explicit SIGTERM:

kill -15 PID

Method 2: Using kill -9 (Force Kill)

If gentle kill doesn't work, force kill immediately:

kill -9 PID

Example:

kill -9 12345

⚠️ kill -9 does not allow any cleanup. Use only as last resort.

Method 3: Using pkill (Kill by Name)

Kill all processes with a specific name:

pkill process-name

Example:

pkill nginx

Force kill by name:

pkill -9 nginx

Method 4: Using killall (Kill by Exact Name)

killall process-name

Example:

killall apache2

Method 5: Kill from top/htop Interactive

In top:

  1. Press k
  2. Enter the PID
  3. Enter signal (15 for gentle, 9 for force)

In htop:

  1. Select process with arrow keys
  2. Press F9
  3. Select SIGTERM (15) or SIGKILL (9)
  4. Press Enter

Understanding Kill Signals

Most common signals:

  • SIGHUP (1) - Reload configuration
  • SIGINT (2) - Interrupt (like Ctrl+C)
  • SIGTERM (15) - Terminate gracefully (default)
  • SIGKILL (9) - Force kill immediately
  • SIGSTOP (19) - Pause process
  • SIGCONT (18) - Resume paused process

Kill All Frozen Processes of a User

pkill -u username

Force kill all user processes:

pkill -9 -u username

Kill All Processes Except Specific Ones

Kill all except your SSH session (advanced):

kill -9 -1

⚠️ The above command will kill ALL processes including your SSH session!

Check if Process is Still Running After Kill

ps aux | grep PID

Or:

kill -0 PID

Returns success if process exists.

Common Scenarios

Apache/Nginx is frozen:

systemctl restart nginx

Instead of killing individually.

MySQL not responding:

systemctl restart mysql

User program frozen (like Python script):

pkill -f "python script.py"

Automatically Kill High-Memory Processes (Monitor Script)

#!/bin/bash
MAX_MEM=80  # 80% memory usage
MEM_USED=$(free | grep Mem | awk '{print ($3/$2) * 100}')
if (( $(echo "$MEM_USED > $MAX_MEM" | bc -l) )); then
    ps aux --sort=-%mem | head -5 | awk '{print $2}' | xargs kill -9
fi

✅ You can now terminate frozen or problematic processes on your Hostxpeed VPS.

Was this article helpful?