I am a regular user on a remote Debian installation (not an administrator). I run there a special-purpose network server which is used very extensively. The server produces daily logs which are quite large, and from time to time I need to pack them into a monthly tar-ball and, after some more time, compress them. First I tried this:tar rf 2014-12.tar 2014-12-*.log10 minutes later a customer called and told that the server had stopped responding. Indeed, the server process was put aside, and all attention was given to the tar process, although the total CPU load, according to top, was only 5 percent. Then I tried:nice -n19 tar rf 2014-12.tar 2014-12-*.log &I sent the command to the background to be able to monitor the server process. I observed that the server process had slowed down, but not too much, so it was acceptable. It all worked for maybe 5 minutes, and then suddenly the server stalled again. I killed the tar process and saw the server immediately rush to work.The server is listening on a TCP socket where many clients are connecting. When tar is running, the server continues to work, but after some time the select call seems to stop updating readable sockets.All this is confusing. The server seems to be cut off after few minutes when something else is running, but otherwise it runs without problems for months. It also seems, according to top, that my processes never get more than about 5 percent of CPU total, why would that be? How can I pack the logs without disturbing my server process?
`nice` not really helping on Linux
linux;nice
As muru stated,nice only controls CPU scheduling. You yourself noted that CPU usage was only about 5% at the time. This means that the system was heavily IO-bound, meaning reading/writing the disks was the bottleneck.You can control the IO priority given to a process via the ionice command. You can put a process in one of three scheduling classes:idle - will only get disk time when no other program needs the diskbest-effort - basically the defaultrealtime - this class gets first access to the disk, no matter what else is going onYou can specify the class with the -c option, 1 = realtime, 2 = best-effort, 3 = idle.With best-effort and realtime there are also 8 different priority levels, to fine tune amongst processes of the same class.I usually execute commands such as tar or rsync with ionice -c3, i.e. the lowest class idle. That way other process aren't starved of disk access.Note that IMHO ionice works best with the CFQ I/O scheduler (a kernel parameter).