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

AI in 2025: is it an agentic year?

2024 was the GenAI year. With new and more performant LLMs and a higher number…

6 hours ago

Canonical announces 12 year Kubernetes LTS

Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…

1 day ago

Ubuntu Weekly Newsletter Issue 878

Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…

2 days ago

How your feedback shapes the way we support open source software

At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…

2 days ago

How To Install osTicket v1.14 On Ubuntu 20.04

I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…

4 days ago

How To Install WordPress On Ubuntu 20.04

Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…

4 days ago