Runing a nightly backup script on a server system like a webhosting server can produce high load and longer latencys for other processes, e.g. HTML or .php pages load slow during backup because the backup script takes too much I/O or CPU resources.

On Linux systems there are two shell utilitys available to set the I/O and CPU Scheduling for a appliaction or script. The utilitys are named nice and ionice.

Reduce the I/O priority of the script "/usr/local/bin/backup.sh" so that it does not disrupt 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.

To reduce the CPU priority, use the command nice:

/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

 

Reduce load of backup scripts with nice and ionice
Tagged on:         

One thought on “Reduce load of backup scripts with nice and ionice

  • Permalink

    Add nocache to that and you’re set (you can join it with ionice and nice):
    https://github.com/Feh/nocache

    On Ubuntu install with:
    apt install nocache

    It simply omits cache on IO and thanks to that other processes won’t starve when the cache is flushed.
    It’s like calling the commands with O_DIRECT.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Ad #native_company# — #native_desc# #native_cta#