Log In | Register | March 26, 2019

Share
 

Linux - June 19, 2012

Identify CPU/memory intensive processes, adjust process priority with renice, and kill processes.

Identifying problems on a system is very important and can save headaches for the future. You can use utilities such as ps, top, kill, and renice to manage and monitor processes on your Linux system.

Using the Linux ps utility

This utility is used to output a snapshot of your current processes. ps displays information about various active processes. There are many flags you can use along with ps, below I will list a few examples.

To see every process on the system using standard syntax:
ps -e
ps -ef
ps -eF
ps -ely

To see every process on the system using BSD syntax:
ps ax
ps axu

You can find more examples using the man pages as such.

man ps

Using the top utility

The top utility displays a dynamic real-time view of the running tasks on your system. It also displays system summary information as far as CPU usage, memory usage, your uptime and more.

In order to use top simply type top in your terminal.

top

After top is running you will be able to interact with the program by using various commands. For instance if you needed to sort by a particular column you could use shift f. This would then display options for you to choose from for your sort.

You can also kill process or change their priority in top by using either the letter k or r. Top also has a help menu that you can access once you’re running the program. Type the ? key in order to access it.

Using the kill utilities

The kill utility can come in handy when you need to kill a particular process. You can call a process using the process id or the process name. There are 2 tools that you need to be familiar with, kill and killall.

Using kill

If you wanted to use kill to end a process based on the process id you would use the following.

kill 2012

The number 2012 you would replace with the process id of the application you want to kill. You could also kill a process based on the name. For instance, lets say we wanted to stop the process named firefox. We would use the following.

killall firefox

Both tools also offer various flags to handle certain processes in certain ways. For instance the -9 flag can be added to either kill or killall and it will kill the signal immediately.

Using the renice utility.

The renice utility allows you to prioritize your processes. This is helpful when you want to make sure a particular process finishes or runs compared to other processes. The range for the priorities are from -20 to 19. The lower the the number the higher the priority.

Note* Only root can set the priority to less then 0.

In order to use renice you would do the following.

renice -20 process_id

The above command sets the process with the highest priority of -20. You would replace process_id with your actual process id.

Post By: | FavoriteLoadingAdd to favorites

0 Comments

Leave a Comment



Need Help? Ask a Question

Ask anything you want from how to questions to debug. We're here to help.

You Must Be Logged In To Post A Question.

Log In or Register