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

Web Engineering: Celebrating Our Third Annual Hack Week

The Web Engineering team is thrilled to announce the successful conclusion of our third annual…

2 days ago

🚀 Deploy Flowise + Kubernetes + Helm on Ubuntu VPS (10-Step Guide)

Here’s a step-by-step guide to deploy FlowiseAI (commonly just Flowise) on a Ubuntu VPS using…

2 days ago

Azure VM utils now included in Ubuntu: boosting cloud workloads

Ubuntu images on Microsoft Azure have recently started shipping with the open source package azure-vm-utils…

3 days ago

Edge Networking gets smarter: AI and 5G in action

Organizations everywhere are pushing AI and networks closer to the edge. With that expansion comes…

3 days ago

When Your Hash Becomes a String: Hunting Ruby’s Million-to-One Memory Bug

Every developer who maintains Ruby gems knows that sinking feeling when a user reports an…

4 days ago