📞 🇺🇸 +1 361 304 4309 📞 🇮🇳 +91 76769 02281 ✉️ [email protected]
Troubleshooting & Fixes

How to Fix High CPU Usage on Linux Server

How to Fix High CPU Usage on Linux Server

High CPU usage slows down or crashes your server. Finding the exact cause quickly is essential — this guide covers systematic diagnosis and fixes.

Step 1 — Identify the Process

# Real-time CPU usage
top -c
# Press P to sort by CPU
# Press 1 to see per-core usage

# More detailed view
htop

# Non-interactive snapshot
ps aux --sort=-%cpu | head -20

Step 2 — Fix PHP-FPM High CPU

# Too many PHP-FPM workers spinning
ps aux | grep php-fpm | wc -l

# Check for infinite loops in PHP
sudo strace -p PHP_PID 2>&1 | head -20

# Restart PHP-FPM
sudo systemctl restart php8.2-fpm

# Reduce workers if overloaded
pm.max_children = 20
pm.max_requests = 500  # Restart workers after 500 requests

Step 3 — Fix MySQL High CPU

# Check for long-running queries
mysql -u root -p -e "SHOW PROCESSLIST;"

# Kill CPU-intensive query
mysql -u root -p -e "KILL QUERY process_id;"

# Check for missing indexes causing full table scans
mysql -u root -p -e "SHOW STATUS LIKE 'Select_full_join';"

Step 4 — Fix WP-Cron CPU Spikes

# WP-Cron running too frequently
grep "wp-cron" /var/log/nginx/access.log | wc -l

# Disable WP-Cron and use real cron
define('DISABLE_WP_CRON', true);

# Add to real cron
*/5 * * * * wp --path=/var/www/html cron event run --due-now --quiet

Step 5 — Check for Malware Using CPU

# Suspicious processes using high CPU
ps aux --sort=-%cpu | head -20
# Check any unknown processes

# Check for crypto miners
ps aux | grep -E "minerd|xmrig|cpuminer|kworker"

# Check network connections for mining pools
netstat -tulpn | grep -E "3333|4444|5555|8333"

Step 6 — Fix Runaway Cron Jobs

# Check all crontabs
crontab -l
sudo crontab -l
cat /etc/crontab
ls /etc/cron.d/

# Check currently running cron jobs
ps aux | grep cron

Conclusion

High CPU issues need immediate identification and fixing. Our team provides emergency server performance support with 15-minute response time.

#cpu #high-usage #performance #linux #troubleshooting
Share this guide:
🛠️ Need Expert Help?

Don't want to do this yourself?

Our certified engineers implement this for you — correctly, securely, and within hours. Available 24/7 with 15-minute emergency response.

  • ✅ 19+ years experience
  • ✅ 60+ certified engineers
  • ✅ 1,600+ servers managed
  • ✅ 40+ countries served
  • ✅ Plans from $49/mo

Get Expert Help — Free Consultation

We respond within 4 hours · No commitment required

Please enter your name and a valid email.

No spam. Privacy Policy

Comments