A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Hot answers tagged

121

From htop source code, file UptimeMeter.c, you can see: char daysbuf[15]; if (days > 100) { sprintf(daysbuf, "%d days(!), ", days); } else if (days > 1) { sprintf(daysbuf, "%d days, ", days); } else if (days == 1) { sprintf(daysbuf, "1 day, "); } else { daysbuf[0] = '\0'; } I think ! here is just a mark that server has been up for more ...


114

htop author here. Yes, as others already mentioned, it indeed shows up after 100 days of uptime. The reason is nothing fancy, it's just an Easter egg in the software. Consider that the program is impressed with your uptime, and take it as you will. :)


93

Here is the laziest way (or homebrew way) First install Homebrew if you haven't Second brew install htop Third, done


47

htop has a setup screen, accessed via F2, that allows you to customize the top part of the display, including adding or removing a "Load average" field and setting it's style (text, bar, etc.). These seem to be auto saved in $HOME/.config/htop/htoprc, which warns: # Beware! This file is rewritten by htop when settings are changed in the interface. # The ...


35

htop shows the exclamation mark when the server has been up since 100 or more days. While once system administrators had pride in showing long uptimes, nowadays the system has to be rebooted to be kept up to date with new kernels and some security fixes. For such reason, a long uptime is probably not a good thing and I tend to interpret the exclamation mark ...


33

The easiest way is to use the setup in the program and then save and exit the program with F10, not with CTRL+C. Next time you can close the program the way you like.


26

F1 or h will show you the legend. It looks like in this color scheme: CPU: blue is for low priority threads green is normal priority threads black is for io-wait see below for more. Memory: green is memory in use blue is buffer orange is cache


23

Something like this? (while kill -0 $pid; do sleep 1; done) && echo "finished" Replace $pid with the process id and echo "finished" with whatever you want to do when the process exited. For example: (while kill -0 $pid; do sleep 1; done) && mail ...


22

As far as I know, the only way to show the full command line is to scroll right with the arrow keys or to use a terminal with a small font. EDIT (thanks to @LangeHaare): You can use Ctrl-A and Ctrl-E to jump to the beginning and end the command line.


16

From man htop: INTERACTIVE COMMANDS Space Tag or untag a process. Commands that can operate on multiple processes, like "kill", will then apply over the list of tagged processes, instead of the currently highlighted one. U Untag all processes (remove all tags added with the Space key). F9, k "Kill" process: sends a ...


12

I use this script (from this thread on the Arch boards): #!/bin/bash read cpu a b c previdle rest < /proc/stat prevtotal=$((a+b+c+previdle)) sleep 0.5 read cpu a b c idle rest < /proc/stat total=$((a+b+c+idle)) CPU=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))


12

Red represents the time spent in the kernel, typically processing system calls on behalf of processes. This includes time spent on I/O. There’s no point in trying to reduce it just for the sake of reducing it, because it’s not time that’s wasted — it’s time that’s spent by the kernel doing useful stuff (as long as you’re not thrashing, so look at the number ...


10

I installed htop 0.8 (update: now 2.0.1) from MacPorts with sudo port install htop


10

A complete re-write of my previous post. Got a bit curious and checked out further. In short: the reason for the difference is that openSUSE uses a patched version of top and free that adds some extra values to `cached'. A) Standard version top, free, htop, ...: Usage is calculated by reading data from /proc/meminfo: E.g.: #free: Row Column | ...


10

If you run a fake job such as sleep 120 and then watch it in htop you'll notice that its state is S aka "SLEEP" and the processes TIME remains at 0:00.00 for the duration. That's because that process is consuming 0 CPU time, which is the intent of the TIME column. It tracks the amount of CPU time a given process has used.      &...


10

I wrote process_watcher.py process_watcher --pid 1234 --to me@gmail.com Currently, email body looks like: PID 18851: /usr/lib/libreoffice/program/soffice.bin --writer --splash-pipe=5 Started: Thu, Mar 10 18:33:37 Ended: Thu, Mar 10 18:34:26 (duration 0:00:49) Memory (current/peak) - Resident: 155,280 / 155,304 kB Virtual: 1,166,968 / 1,188,216 ...


10

Have a look at cgroups, it should provide exactly what you need - CPU reservations (and more). I'd suggest reading controlling priority of applications using cgroups. That said, put the important yet often idle processes into group with allocated 95% of CPU and your other applications into another one with allocated 5% - you'll get (almost) all of the power ...


10

It is because htop is counting buffers and cached memory as free memory, because it can actually can be seen this way. There is no "cost" in having some cached data in memory, so the kernel keep stuff there just in case it needs afterwards. For instance, suppose you have watched a video of about 500mb, after you close the video, the kernel may decide to ...


10

From the ps manual on macOS (my emphasis): -a Display information about other users' processes as well as your own. This will skip any processes which do not have a controlling terminal, unless the -x option is also specified. Applications that are running on macOS without a controlling terminal, such as windowed Finder applications, will not be ...


9

You could run top in batch mode -b with 1 iteration -n1. You grep it, pipe it to awk, SUM the result and print it. top -b -n1 | grep chrome | awk '{ SUM += $9} END { print SUM }' I don't know which column you want to output. Change $9 to fit your needs.


9

A similar question was asked on superuser in February https://superuser.com/questions/1036978/how-pause-list-of-process-in-htop The accepted answer is to use the -d option to change the delay of the refresh. From the man page: -d --delay=DELAY Delay between updates, in tenths of seconds e.g. htop -d 100 to refresh every 10 seconds. Judging by ...


8

The mistake was to presume those numbers were PIDS, when in fact they are TIDS (thread IDs). See Linux function gettid(2). Reading up on clone(2) gives a lot of extra (and interesting) details.


7

This is not possible, as of htop 0.8.3. Source: the source code. The best you can do is sort processes by user, root's processes will be conveniently lumped together.


7

Pre-built binary Found this tutorial that shows how to do it. The steps are as follows: $ curl -O http://themainframe.ca/wp-content/uploads/2011/06/htop.zip $ unzip htop.zip $ sudo mv htop /bin $ rm htop.zip This binary is already pre-built so you should use caution when using executables such as this to make sure that they aren't malicious. Building it ...


7

Pressing H in htop group the processes by the main thread (command), actually it toggles the threads visibility.


7

This is possible in atop. Just press p when running it. From the help: Accumulated figures: 'u' - total resource consumption per user 'p' - total resource consumption per program (i.e. same process name) 'j' - total resource consumption per container


7

I am wondering why top and htop don't display -100 for higest priority real time processes ? That's because SCHED_RR and SCHED_FIFO have fixed static priorities from 1-99: Source For realtime priorities, the order is reversed: 99 is indeed the highest one, contrary to the ususal "lower is higher". Per your comment I misunderstood your question, sorry. ...


7

Go to settings (F2), under Meters, you select what is in the left column and what in the right column. Instead of CPUs (1/1) in the left column, select CPUs (1/2) for the left column and CPUs (2/2) for the right column. F10 to save the changes and it's done.


7

Under Linux, you can do: htop -p `pstree -p $PID | perl -ne 'push @t, /\((\d+)\)/g; END { print join ",", @t }'` where $PID is the root process. This works as follows: The list of the wanted processes are obtained with pstree, using the -p option to list them with their PID. The output is piped to a Perl script that retrieves the PID's, using a regular ...


7

Ok, that was easy. Although it is not particularly well explained in the man page, after some tinkering in the setup I found an answer. Press F2 and using Enter and arrows setup the following for Layout 1:, For Layout 2 setup this:


Only top voted, non community-wiki answers of a minimum length are eligible