If you know that your system is running
If you know that your system is running low on CPU capacity, you can choose to start a command with nice(1) to assign the command a priority. Specify the desired niceness level by putting a single dash in front of the command. For example, to start a make buildworld at nice 15, you would run this command: ………………………………………………………………………………………. # cd /usr/src # nice -15 make buildworld ………………………………………………………………………………………. Only root can assign a negative niceness to a program. To run a program with negative niceness, use a double dash (nice –5). For example, if you have a critical kernel patch that must be applied as soon as possible, and you want the compile to finish as quickly as possible, use a negative niceness like so: ………………………………………………………………………………………. # cd /sys/i386/compile/MYKERNEL # nice –20 make depend && nice –20 make all install ………………………………………………………………………………………. Usually, you won’t have the luxury of telling a command to start off nicely, but will instead need to change a process’s niceness on the fly (generally, when you find out that it’s soaking up all your CPU). You can do so with renice(8), which will reprioritize by process ID or owner. To change the niceness of a process ID, you run renice with the new niceness and the process ID. For example, one of my systems has a FreeBSD CVSup mirror. If I find that the mirror is taking up so much CPU time that it’s getting in the way of things I have to do, I can change its niceness to 20. The maximum niceness we can use is 20, which basically tells the system to run this command only if nothing else at all wants CPU time. To renice a running process, I first need to know its process ID. I know the process is named cvsupd because I’ve looked at this system’s top output over the last several months. I then look at all the processes running on the system, and pull out the one for cvsupd with the following command: ………………………………………………………………………………………. # ps -ax | grep cvsupd 322 ?? Is 0:00.01 /usr/local/sbin/cvsupd -C 5 -b /test2 -s sup # ………………………………………………………………………………………. The first column in the preceding ps output is the process ID, PID 322. Now to renice it, I would enter the following: ………………………………………………………………………………………. # renice 20 322 322: old priority 0, new priority 20 # ………………………………………………………………………………………. Boom! The cvsupd daemon will now only run when nothing else requiring system time is running. This will greatly annoy users of the service, of course, but I presumably have a good reason for doing so. (Since this is a private mirror, not a public one, I feel no particular need to be kind to my users.) 413
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services