How to limit CPU and disk usage of rm to allow other programs to remain functional

3

When deleting a large file, rm seems to be hogging all the available CPU and disk resources so that other program are hanging.

Is there a way to limit a programs - specifically a CPU or disk intensive program - effect on the system? Is there a way to limit its effect when deleting a large file?

user217631

Posted 2012-04-10T17:06:31.140

Reputation: 175

Answers

5

nice (see here) is the program to do that for you. You can use renice for a running program. Note that this only does CPU, there is a corresponding ionice (see here)

Jeff Foster

Posted 2012-04-10T17:06:31.140

Reputation: 526

0

GETRLIMIT(2)

NAME
       getrlimit, setrlimit, prlimit - get/set resource limits

SYNOPSIS
       #include <sys/time.h>
       #include <sys/resource.h>

       int getrlimit(int resource, struct rlimit *rlim);
       int setrlimit(int resource, const struct rlimit *rlim);
       int prlimit(pid_t pid, int resource, const struct rlimit *new_limit,
               struct rlimit *old_limit);

Andrew Tomazos

Posted 2012-04-10T17:06:31.140

Reputation: 147