Learn how to quickly identify and kill stuck Python or Node.js processes in cPanel to free up server resources and keep your applications running smoothly.

Why Would You Need to Kill a Process?

Sometimes, Python or Node.js applications can become unresponsive, consume excessive resources, or fail to terminate properly. When this happens, you may need to manually stop these processes in cPanel to:
✔ Free up server memory & CPU
✔ Resolve application crashes
✔ Restart failed services
✔ Prevent server slowdowns

Steps to Check and Kill Processes via cPanel Terminal

  1. Log in to cPanel.

  2. Go to the "Advanced" section and locate "Terminal."

    Note: If you cannot find this feature, contact support and request to enable Terminal in your cPanel.

  3. List all running processes by typing:

     
    ps faux

Output.

Kill Processes via cPanel Terminal - ps faux command

How to Kill All Python or Node.js Processes in cPanel

Terminating Python Processes

To kill all processes associated with Python, run the following command:

kill -9 $(ps faux | grep python | grep -v grep | awk '{print $2}')

Terminating Node.js Processes

To kill all processes associated with Node.js, use this command:

kill -9 $(ps faux | grep node | grep -v grep | awk '{print $2}')

After running ps faux again, you should no longer see the Python or Node.js processes running.

Alternative

For Python Processes:

pkill -f python

(or pkill -f python3 for Python 3)

For Node.js Processes:

pkill -f node

Command Breakdown

This command performs the following steps:

  1. ps faux – Lists all running processes in a tree format.

  2. grep python/node – Filters processes containing "python" or "node."

  3. grep -v grep – Excludes the grep command itself from results.

  4. awk '{print $2}' – Extracts the Process IDs (PIDs) from the output.

  5. kill -9 $(...) – Forcefully terminates the listed PIDs.

  6. pkill terminates running processes by name (instead of manually finding and killing them by PID). 

Automating with a Cron Job

To automatically kill Python processes every 30 minutes, add this to your crontab:

*/30 * * * * kill -9 $(ps faux | grep python | grep -v grep | awk '{print $2}')

⚠️ Caution:

  • Only use kill -9 if processes are unresponsive (normal termination should use kill -15 first).

  • Improper cron job usage may disrupt critical services.

FAQs

Q: What if the process keeps reappearing?

A: It may be auto-started by a cron job or service. Check:

  • Cron jobs in cPanel

  • Startup scripts

Q: Will killing a process delete my data?

A: No, but unsaved work in the app may be lost.

Q: Can I automate process cleanup?

A: Yes! Use a bash script to monitor and kill high-resource processes.

Was this answer helpful? 0 Users Found This Useful (0 Votes)