Reduce CPU and Disk load of backup scripts with nice and ionice

Running a nightly backup script on a server system, such as a web hosting server, can result in a heavy load and longer latency for other processes, for example, HTML or .php pages load slowly during the backup because the backup script requires too many I/O or CPU resources.

On Linux systems, two shell utilities are available to set I/O and CPU scheduling for an application or script. The utilities are named nice and ionice.

Reduce the I/O priority of the /usr/local/bin/backup.sh script so that it does not interfere with other processes:

/usr/bin/ionice -c2 -n7 /usr/local/bin/backup.sh

The -n parameter must be between 0 and 7, where lower numbers mean higher priority.

Sponsored

To reduce the CPU priority, use the command nice:

Sponsored
/usr/bin/nice -n 19 /usr/local/bin/backup.sh

The -n parameter can range from -20 to 19, where lower numbers mean higher priority

Nice and ionice can also be combined, to run a script at low I/O and CPU priority:

/usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /usr/local/bin/backup.sh

The post Reduce CPU and Disk load of backup scripts with nice and ionice appeared first on FAQforge.

Ubuntu Server Admin

Recent Posts

Canonical Releases Ubuntu 25.04 Plucky Puffin

The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

21 hours ago

Ubuntu 25.04 (Plucky Puffin) Released

Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

2 days ago

Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

2 days ago

Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

Focal Fossa will reach the End of Standard Support in May 2025, also known as…

3 days ago

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

3 days ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

4 days ago