Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I run some commands repeatedly?

Status
Not open for further replies.

kanghao

IS-IT--Management
Jul 4, 2004
68
KR
How can I run some commands repeatedly?

for example I want to print "ps -ef | grep Exus | wc -l"

the below won't work.

while true do "ps -ef | grep Exus | wc -l ;sleep 1" done;

Thanks.
 
while true
do
ps -ef | grep Exus | wc -l
sleep 1
done


Please try it this way
 

Thanks. finally it works.

while true; do ps -ef | grep Exus | wc -l; sleep 1; done;
 
How can I add the time excuted?
like
2005/10/10 18:07:19 3
(time, number of processes)
 
while true; do ps -ef | grep Exus | wc -l; sleep 1;date;done;
 
I mean concatenate the process number and date in one line.

like
2005/10/10 18:07:19 => 3
2005/10/10 18:07:29 => 2
 
while true; do ps -ef | grep Exus | echo `date` = `wc -l`; sleep 1;done;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top