{"id":13248,"date":"2019-04-01T09:44:22","date_gmt":"2019-04-01T09:44:22","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13248"},"modified":"2019-04-01T09:44:22","modified_gmt":"2019-04-01T09:44:22","slug":"find-top-running-processes-by-highest-memory-and-cpu-usage-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/01\/find-top-running-processes-by-highest-memory-and-cpu-usage-in-linux\/","title":{"rendered":"Find Top Running Processes by Highest Memory and CPU Usage in Linux"},"content":{"rendered":"<p>I remember once reading that efficient system administrators are lazy people. The reason is not that they\u2019re not doing their job or wasting their time \u2013 it is mostly because they have automated a good deal of their routine tasks. Thus, they don\u2019t have to babysit their servers and can use their time to learn new technologies and always stay at the top of their game.<\/p>\n<p>Part of automating your tasks, is learning how to get a script do what you would have to do yourself otherwise. Continually adding commands to your own knowledge base is just as important.<\/p>\n<p>For that reason, in this article we will share a trick to find out, which processes are consuming lots of Memory and CPU utilization in Linux.<\/p>\n<div id=\"attachment_21853\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Find-Linux-Processes-By-RAM-and-CPU-Usage.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-21853\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Find-Linux-Processes-By-RAM-and-CPU-Usage.png\" alt=\"Find Linux Processes By RAM and CPU Usage\" width=\"720\" height=\"345\" aria-describedby=\"caption-attachment-21853\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-21853\" class=\"wp-caption-text\">Find Linux Processes By RAM and CPU Usage<\/p>\n<\/div>\n<p>That said, let\u2019s dive in and get started.<\/p>\n<h3>Check Top Processes sorted by RAM or CPU Usage in Linux<\/h3>\n<p>The following command will show the list of top processes ordered by RAM and CPU use in descendant form (remove the\u00a0<strong>pipeline<\/strong>\u00a0and\u00a0<strong>head<\/strong>\u00a0if you want to see the full list):<\/p>\n<pre># ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head\r\n<\/pre>\n<h5>Sample Output<\/h5>\n<pre>PID  \tPPID \tCMD                      \t%MEM \t%CPU\r\n2591\t2113 \t\/usr\/lib\/firefox\/firefox    7.3 \t43.5\r\n2549   2520 \t\/usr\/lib\/virtualbox\/Virtual 3.4  \t8.2\r\n2288       1 \t\/home\/gacanepa\/.dropbox-dis\t1.4\t0.3\r\n1889   1543\tc:\\TeamViewer\\TeamViewer.ex\t1.0\t0.2\r\n2113\t1801\t\/usr\/bin\/cinnamon\t\t0.9\t3.5\r\n2254\t2252\tpython \/usr\/bin\/linuxmint\/m\t0.3\t0.0\r\n2245\t1801\tnautilus -n\t\t\t0.3\t0.1\r\n1645\t1595\t\/usr\/bin\/X :0 -audit 0 -aut\t0.3\t2.5\r\n<\/pre>\n<div id=\"attachment_21848\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Find-Top-Processes-By-RAM-and-CPU-Usage.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-21848\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/07\/Find-Top-Processes-By-RAM-and-CPU-Usage.png\" alt=\"Find Top Processes By RAM and CPU Usage\" width=\"559\" height=\"212\" aria-describedby=\"caption-attachment-21848\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-21848\" class=\"wp-caption-text\">Find Top Processes By RAM and CPU Usage<\/p>\n<\/div>\n<p>Brief explanation of above options used in above command.<\/p>\n<p>The\u00a0<code>-o<\/code>\u00a0(or\u00a0<strong>\u2013format<\/strong>) option of\u00a0<strong>ps<\/strong>\u00a0allows you to specify the output format. A favorite of mine is to show the processes\u2019\u00a0<strong>PIDs<\/strong>\u00a0(<strong>pid<\/strong>),\u00a0<strong>PPIDs<\/strong>\u00a0(<strong>pid<\/strong>), the name of the executable file associated with the process (<strong>cmd<\/strong>), and the RAM and CPU utilization (<code>%mem<\/code>\u00a0and\u00a0<code>%cpu<\/code>, respectively).<\/p>\n<p>Additionally, I use\u00a0<code>--sort<\/code>\u00a0to sort by either\u00a0<code>%mem<\/code>\u00a0or\u00a0<code>%cpu<\/code>. By default, the output will be sorted in ascendant form, but personally I prefer to reverse that order by adding a minus sign in front of the sort criteria.<\/p>\n<p>To add other fields to the output, or change the sort criteria, refer to the\u00a0<strong>OUTPUT FORMAT CONTROL<\/strong>\u00a0section in the man page of\u00a0<code>ps<\/code>\u00a0command.<\/p>\n<p><b>Don\u2019t Miss:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/find-processes-by-memory-usage-top-batch-mode\/\" target=\"_blank\" rel=\"noopener\">Find Top 15 Processes by Memory Usage with \u2018top\u2019 in Batch Mode<\/a><\/p>\n<p><b>Don\u2019t Miss:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/find-top-large-directories-and-files-sizes-in-linux\/\" target=\"_blank\" rel=\"noopener\">Find top 10 Directories Disk Size in Linux<\/a><\/p>\n<h3>Summary<\/h3>\n<p>Monitoring process is one of the numerous tasks of a Linux server system administrator, in this tip, we looked at how you list processes on your system and sort them according to\u00a0<strong>RAM<\/strong>\u00a0and\u00a0<strong>CPU<\/strong>\u00a0use in descendant form using the\u00a0<strong>ps<\/strong>\u00a0utility.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/find-linux-processes-memory-ram-cpu-usage\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I remember once reading that efficient system administrators are lazy people. The reason is not that they\u2019re not doing their job or wasting their time \u2013 it is mostly because they have automated a good deal of their routine tasks. Thus, they don\u2019t have to babysit their servers and can use their time to learn &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/01\/find-top-running-processes-by-highest-memory-and-cpu-usage-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Find Top Running Processes by Highest Memory and CPU Usage in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13248","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13248"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13248\/revisions"}],"predecessor-version":[{"id":13249,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13248\/revisions\/13249"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}