RE: Regarding top command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

> -----Original Message-----
> From: redhat-list-bounces@xxxxxxxxxx 
> [mailto:redhat-list-bounces@xxxxxxxxxx] On Behalf Of Krishnaprasad
> Sent: Friday, June 02, 2006 2:02 AM
> To: General Red Hat Linux discussion list
> Subject: Regarding top command
> 
> Hi all
>       
>        Is there any way to run top command as a background process?
> 
> I have tried "top -n1 &" and then "fg %1". it works fine from 
> the terminal but from a script i am not able to call fg command.
> 
> Is there any other way for this ..
> 
> thanks for ur time..
> 
> rgds
> krishnaprasad

I'm not sure I understand what you are trying to do.

As far as I know, fg will not work in a script (I could be wrong, though).
But if all you want is to start top, then do other commands while top is
running in the background, then wait for top to end, there may be a way.

I couldn't get 'top' to work in the background in a script because it was
failing on a tty get so I redirected standard input. The below worked for
me.

Is this what you want?

----- START OF SCRIPT

#!/bin/bash
top -n5 < /dev/console &
PID=`jobs -p`

wait $PID

----- END OF SCRIPT

Hope this helps,
Michael

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux