Making Processes Play Nice with Linux nice and ionice
Dots pattern

Linux nice & ionice: Prevent Background Jobs from Impacting Production

When hosting applications for different applications and websites, we need to run multiple different kinds of maintenance tasks on a server to make sure security is up to date, settings are provisioned, security scans are run, and a raft of other things.

An example is running a WordPress security scan during a traffic spike. The scan chews CPU and disk, PHP workers back up, pages slow down… and suddenly you’re dropping real users and real revenue.

Other such maintenance tasks include:

  • Security scans
  • CMS and plugin audits (WordPress, Drupal, etc.)
  • Malware detection
  • File integrity checks
  • Backups
  • Log analysis
  • Provisioning and configuration management

All of these are necessary, but if you’re not careful, they can crash performance at the worst time.

This is where nice and ionice come in handy.

NICE - CPU Priority

nice controls CPU scheduling priority for a process.

Linux uses a numeric “niceness” value from -20 to 19:

  • 20 → highest priority (least nice to others)
  • 0 → default
  • 19 → lowest priority (most nice to others)

The higher the number, the lower the priority.

For maintenance tasks like security scans, malware detection, or plugin audits, we want them to run — just not at the expense of live traffic.

Running a Command With nice

You can start a process with a lower CPU priority like this:

nice -n 15 wp plugin list

This basically tells the Linux scheduler: “Run this, but let everything else go first.”

Which results in:

  • Web requests stay responsive
  • Short CPU bursts from real users take precedence

These are really useful when:

  • Running scans outside normal hours but not guaranteed quiet hours
  • Operating on shared or multi-tenant servers
  • Running cron jobs that must complete but aren’t time-critical

Changing Priority of a Running Process

If something is already running and you realise it’s being too aggressive:

renice 15 -p <PID>

IONICE - Disk IO Priority

CPU isn’t the only thing that will starve an active site of resources.

We’ve seen a lot of sites start dropping requests because of disk IO saturation, not CPU exhaustion.

We can improve that by using ionice .

ionice controls how aggressively a process can access disk IO, which is useful when:

  • Scanning large WordPress installs
  • Traversing millions of small files
  • Running malware or integrity checks
  • Performing backup verification

IO Scheduling Classes

The most useful classes are:

  • Class 2 – Best Effort (default)
  • Class 3 – Idle (only runs when disk is otherwise idle)

For background scans and non-critical processes, Idle is usually what you want.

Running a Command With ionice

ionice -c3 wp plugin list

This means “Only touch the disk when nothing more important needs it.”

This makes sure

  • Databases stay responsive
  • Web Requests doesn’t block on disk reads
  • Other applications or sites aren’t impacted

Using nice and ionice Together

In almost all maintenance scenarios, we want to make sure neither the CPU or IO is saturated

Such an example for an intensive scan may be

nice -n 19 ionice -c3 clamscan -r /srv/example.com

The above commands ensures

  • The scan runs eventually
  • Web requests get the CPU when they need it
  • Sudden spikes don’t cause outages
  • We don’t make mistakes when timing maintenance tasks

Looking for a hosting provider for your website or applications? Contact our team at our Adelaide Head Office to discuss custom hosting solutions that fit your business perfectly.

Digitize, Adelaide, SA 5000, Australia

Phone: +61 (08) 7081 1100

Related articles

Unveiling the Challenges of Ecommerce: Navigating the Path to Success

Navigate the path to success with our comprehensive eCommerce solutions. From robust online storefronts to seamless payment integrations, we provide all the tools you need to thrive in the digital marketplace. Partner with us and transform your eCommerce vision into a profitable reality.

Read More

The Importance of WordPress Updates

WordPress updates are crucial for the security, performance, and functionality of your website. They provide patches for known vulnerabilities, fix bugs, and introduce new features and improvements. Regular updates ensure your website remains secure, runs smoothly, and offers the best user experience. Neglecting updates can leave your site vulnerable to attacks and performance issues

Read More

What is Microsoft SQL Server

Experience the power of advanced data management and analytics with Microsoft SQL Server. Benefit from high performance, enhanced security, and scalable solutions that support your business growth. Harness the potential of your data, make informed decisions, and drive your business forward with Microsoft SQL Server.

Read More
Get In Touch

Why partner with Digitize?

At Digitize, we are a focused team that invest constantly in improving so that we can provide the best capabilities to our clients. Our processes and teams are built around being flexible so we can deliver tailored solutions instead of trying to make existing solutions fit.

Each client has a dedicated account manager that will ensure you are always getting the best service possible.