当前在线人数12371
echo q | top - 未名空间精华区
首页 - 版面精华区 - 电脑网络精华区 - Linux 操作系统版精华区 - 精华区文章阅读 首页
未名交友
[更多]
[更多]
echo q | top

发信人: stlstl (射天狼), 信区: Linux
标  题: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 15:50:21 2004) WWW-POST

Usually, I use "top" to check CPU status, and I type "q" if I want to
terminate "top". Question is how to do the "q" step in a shell script? Thanks
a lot!

--
会捥雕弓如满月
※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 65.254.]
发信人: Deling (流浪歌手), 信区: Linux
标  题: Re: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 16:02:26 2004), 转信

echo q | top
is this what you want?
【 在 stlstl (射天狼) 的大作中提到: 】
: Usually, I use "top" to check CPU status, and I type "q" if I want to
: terminate "top". Question is how to do the "q" step in a shell script? Thanks
: a lot!


--
__("<
\__/
  ^^
One small step for BSD, One giant step for PCs.

※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 128.193.]
发信人: stlstl (射天狼), 信区: Linux
标  题: Re: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 16:08:29 2004) WWW-POST

hey, it works!! Thanks a lot, Deling!

【 在 Deling (流浪歌手) 的大作中提到: 】
: echo q | top
: is this what you want?
: 【 在 stlstl (射天狼) 的大作中提到: 】
: : Usually, I use "top" to check CPU status, and I type "q" if I want to
: : terminate "top". Question is how to do the "q" step in a shell script?
Thanks
: : a lot!
:
:

--
会捥雕弓如满月
※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 65.254.]
发信人: ahaau (阿哈哟), 信区: Linux
标  题: Re: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 16:09:50 2004) WWW-POST

是不是该用

top -n1

【 在 stlstl (射天狼) 的大作中提到: 】
: Usually, I use "top" to check CPU status, and I type "q" if I want to
: terminate "top". Question is how to do the "q" step in a shell script?
Thanks
: a lot!
:

--

※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 128.135.]
发信人: Deling (流浪歌手), 信区: Linux
标  题: Re: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 16:13:14 2004), 转信

seems it does not work on solaris. alternatively, you can do this:
top | cat
when the output is redirected, top regards the output as a dumb terminal.

【 在 ahaau (阿哈哟) 的大作中提到: 】
: 是不是该用
: top -n1
: 【 在 stlstl (射天狼) 的大作中提到: 】
: : Usually, I use "top" to check CPU status, and I type "q" if I want to
: : terminate "top". Question is how to do the "q" step in a shell script?
: Thanks
: : a lot!


--
__("<
\__/
  ^^
One small step for BSD, One giant step for PCs.

※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 128.193.]
发信人: stlstl (射天狼), 信区: Linux
标  题: Re: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 16:24:00 2004) WWW-POST

Now, I found "q | top" has a problem. Here is the simplified script

#!/bin/tcsh
set a = 1

while  ($a < 10)
  echo q | top | grep Safari
  sleep 1
  @ a++
end

Supposed I should see x% for Safari if I am using Safari while running the
script, however, I saw all 0.0%. Not quite right.
I'll try top -nl


【 在 Deling (流浪歌手) 的大作中提到: 】
: seems it does not work on solaris. alternatively, you can do this:
: top | cat
: when the output is redirected, top regards the output as a dumb terminal.
:
: 【 在 ahaau (阿哈哟) 的大作中提到: 】
: : 是不是该用
: : top -n1
: : 【 在 stlstl (射天狼) 的大作中提到: 】
: : : Usually, I use "top" to check CPU status, and I type "q" if I want to
: : : terminate "top". Question is how to do the "q" step in a shell script?
: : Thanks
: : : a lot!
:
:

--
会捥雕弓如满月
※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 65.254.]
发信人: wien (穆先生~星光灭绝), 信区: Linux
标  题: Re: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 16:30:08 2004), 转信

why not use ps? top is an overkill

【 在 stlstl (射天狼) 的大作中提到: 】
: Usually, I use "top" to check CPU status, and I type "q" if I want to
: terminate "top". Question is how to do the "q" step in a shell script? Thanks
: a lot!


--
云在青天水在瓶

※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 128.135.]
发信人: Deling (流浪歌手), 信区: Linux
标  题: Re: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 16:34:51 2004), 转信

it works for me ah, not always 0%, as long as Safari is active.

【 在 stlstl (射天狼) 的大作中提到: 】
: Now, I found "q | top" has a problem. Here is the simplified script
: #!/bin/tcsh
: set a = 1
: while  ($a < 10)
:   echo q | top | grep Safari
:   sleep 1
:   @ a++
: end
: Supposed I should see x% for Safari if I am using Safari while running the
: script, however, I saw all 0.0%. Not quite right.
: I'll try top -nl
: 【 在 Deling (流浪歌手) 的大作中提到: 】
: : seems it does not work on solaris. alternatively, you can do this:
: : top | cat
: : when the output is redirected, top regards the output as a dumb terminal.


--
__("<
\__/
  ^^
One small step for BSD, One giant step for PCs.

※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 128.193.]
发信人: stlstl (射天狼), 信区: Linux
标  题: Re: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 16:48:02 2004) WWW-POST

echo q | top, works, however, for my system I always get 0.0% even if the
specified program is running

top -ln works well here.

ps is not good for me since I basically don't know the job ID, only know the
program name, like Safari

Again, thank you all!


【 在 stlstl (射天狼) 的大作中提到: 】
: Usually, I use "top" to check CPU status, and I type "q" if I want to
: terminate "top". Question is how to do the "q" step in a shell script?
Thanks
: a lot!
:

--
会捥雕弓如满月
※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 65.254.]
发信人: wien (穆先生~星光灭绝), 信区: Linux
标  题: Re: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 16:53:39 2004), 转信

how about
ps -eo "%p   %C   %u  %c" |  grep Safari

【 在 stlstl (射天狼) 的大作中提到: 】
: echo q | top, works, however, for my system I always get 0.0% even if the
: specified program is running
: top -ln works well here.
: ps is not good for me since I basically don't know the job ID, only know the
: program name, like Safari
: Again, thank you all!
: 【 在 stlstl (射天狼) 的大作中提到: 】
: : Usually, I use "top" to check CPU status, and I type "q" if I want to
: : terminate "top". Question is how to do the "q" step in a shell script?
: Thanks
: : a lot!


--
云在青天水在瓶

※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 128.135.]
发信人: perlgolf (perlgolf), 信区: Linux
标  题: Re: unix shell question --- 急!
发信站: Unknown Space - 未名空间 (Thu May 13 18:16:23 2004), 转信

【 在 stlstl (射天狼) 的大作中提到: 】
: echo q | top, works, however, for my system I always get 0.0% even if the
: specified program is running
: top -ln works well here.
: ps is not good for me since I basically don't know the job ID, only know the
: program name, like Safari
: Again, thank you all!

ps -C program_name -o ...

RTFM.

--
                 __          _____
   ___  ___ ____/ /__ ____  / / _/
  / _ \/ -_) __/ / _ `/ _ \/ / _/
/ .__/\__/_/ /_/\_, /\___/_/_/
/_/             /___/

※ 来源:.Unknown Space - 未名空间 mitbbs.com.[FROM: 81.106.]

[返回]
赞助链接
未名交友
将您的链接放在这儿
 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996