LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   htop execute and exit... (https://www.linuxquestions.org/questions/linux-newbie-8/htop-execute-and-exit-782632/)

chamila1986 01-16-2010 02:43 PM

htop execute and exit...
 
I found 'htop' is better than 'top' and Is there a way to execute 'htop' command once and exit...i.e. stop refreshing window and continue console without pressing 'q' or 'ctrl+c'...(like 'top -n 1' in 'top')

GrapefruiTgirl 01-16-2010 04:16 PM

Something to consider is that HTOP doesn't leave any text on the console like TOP does. Does this matter?

Here's a kinda hacky way of doing it, but there may be a better way (htop doesn't seem to like being run any other way than just "run" plain and simple..)

This will run htop for 5 seconds. Change the 5 to less if that's too long:

Code:

#!/bin/sh

{ sleep 5; killall htop; exit; } &

htop

Sasha

colucix 01-16-2010 04:21 PM

Nope. htop is not meant to work in batch mode. Actually this is on the "Feature requests" list, but as far as I know, there is no way to run htop non-interactively or to prevent it from clearing the list of processes when it returns to the command prompt.


All times are GMT -5. The time now is 08:43 PM.