LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-02-2011, 07:36 AM   #1
mesuutt
Member
 
Registered: Jan 2011
Location: İstanbul
Distribution: Slackware,Debian
Posts: 62

Rep: Reputation: 1
Question How to refresh command output automatically?


Hi friends

I want see commands outputs automatically refresh like top command on the console.This is possible?

For example;
I want to see which process most use memory.For this I am using below command.
Code:
ps -aux | sort -nrk 4 | head
But I must execute over and over again .

How am I accomplish this ?

Thanks for help.
 
Old 12-02-2011, 07:41 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You could script it:
Code:
#!/bin bash
while true
do
    ps -aux | sort -nrk 4 | head
    sleep 5
done
Please ask if you need advice on creating and running such a script.
 
Old 12-02-2011, 08:29 AM   #3
mesuutt
Member
 
Registered: Jan 2011
Location: İstanbul
Distribution: Slackware,Debian
Posts: 62

Original Poster
Rep: Reputation: 1
catkin your script is good but I want that command work like top command , so output change in the same place.
This is possible?
 
Old 12-03-2011, 04:07 AM   #4
ottavio
Member
 
Registered: Nov 2007
Posts: 312

Rep: Reputation: 46
What about

Code:
watch -n 5 'ps -aux | sort -nrk 4 | head'
?

But you can achieve the same in top by pressing 'm' and then 'n' and then '4'.
 
1 members found this post helpful.
Old 12-03-2011, 08:34 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
In case you don't go for ottavio's suggestions ...
Quote:
Originally Posted by mesuutt View Post
catkin your script is good but I want that command work like top command , so output change in the same place.
This is possible?
Code:
#!/bin bash
while true
do
    clear
    ps -aux | sort -nrk 4 | head
    sleep 5
done
 
Old 12-04-2011, 08:06 AM   #6
mesuutt
Member
 
Registered: Jan 2011
Location: İstanbul
Distribution: Slackware,Debian
Posts: 62

Original Poster
Rep: Reputation: 1
ottavio's suggestion is perfect for me.
I was looking just thing this
Thanks for helping to all.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get active forum content to refresh automatically EDDY1 LQ Suggestions & Feedback 5 07-17-2011 05:31 AM
GNOME desktop doesn't refresh automatically deesto Linux - General 4 03-04-2010 02:19 AM
Ajax - Need Help to Automatically Refresh Comments farmerjoe Programming 1 07-11-2007 11:52 PM
refresh/monitor output like `top` aunquarra Linux - Software 2 04-13-2007 11:23 AM
Want to refresh Samba shares automatically after Windows reboot evdm Linux - Software 2 03-08-2005 04:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration