grep Vs CPU usage


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers grep Vs CPU usage
# 1  
Old 09-26-2005
grep Vs CPU usage

Hi,

I have one basic doubt, that using grep command frequently , will it have direct impact on the CPU load, pls clarify

for eg, if i run a non stop script containing while loop to grep some parameters, what will be the load in CPU..

thanks
# 2  
Old 09-26-2005
It does. But I dont think there is a direct (or indirect) proportion between them.

Run a grep which goes recursive into the sub directories.

And then issue top. You can see under the %CPU column for the CPU% used for grep.

vino
# 3  
Old 09-26-2005
MySQL

Definitely it does have an impact on CPU usage.

The resources used are in proportion to the complexity of patter.
For eg: for fixed string it will be less. for regular expression it will be more.

To make use of different algorithms for most efficient searches there are seperate binaries itself.

like we have
egrep: extended grep - for regular expression searches
fgrep: fast grep: used for fixed searches across multiple files.

for more information see man pages

thanks,
rishi
# 4  
Old 09-26-2005
Quote:
Originally Posted by vasikaran
Hi,

I have one basic doubt, that using grep command frequently , will it have direct impact on the CPU load, pls clarify

for eg, if i run a non stop script containing while loop to grep some parameters, what will be the load in CPU..

thanks
It sure does, so my advice to you is to "grep smartly", so you narrow down your search as fast as you can, then pipe the results into another grep for processing. While experimenting with scripts, I have brought down my share of servers using grep only (but I can't resist huge one-liners).

Also, when you want an endless loop running, it might be wise to use the sleep-command to add in a pause of a few seconds, just to free up some resources.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

CPU usage

well i want to get the cpu usage of the current processes.the thing is that i want to list the processes with cpu usage=0 and the others(one list for cpu usage=0 and another for cpu usage>0)..i can list them,but i cant find a way to find the ps with cpu usage=0 and cpu usage>0..pls help me with... (6 Replies)
Discussion started by: strawhatluffy
6 Replies

2. UNIX for Dummies Questions & Answers

Need suggestion about grep and CPU usage

guys i need suggestion about how to grep cpu usage and then compare it example : if cpu usage <= 40% then print normal and how much cpu usage is or cpu usage between 40%-65% print normal and much cpu usage is i've tried like this one but got error DOMAIN=`uname -n`... (9 Replies)
Discussion started by: ashary
9 Replies

3. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

4. Solaris

Multi CPU Solaris system shows 100% CPU usage.

Hello Friends, On one of my Solaris 10 box, CPU usage shows 100% using "sar", "vmstat". However, it has 4 CPUs and prstat and glance are not showing enough processes to justify high CPU utilization. ========================================================================= $ prstat -a ... (4 Replies)
Discussion started by: mahive
4 Replies

5. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

6. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

7. Programming

CPU usage and memory usage

Please tell me solaris functions/api for getting following information 1- Function that tells how much memory used by current process 2- Function that tells how much memory used by all running processes 3- Function that tells how much CPU is used by current process 4- Function that tells how... (1 Reply)
Discussion started by: mansoorulhaq
1 Replies

8. Programming

Monitor CPU usage and Memory Usage

how can i monitor usages of CPU, Memory, Hard disk etc. under SUN Solaries through a c program or java program i want to store that data into database so i can show it graphically thanks in advance (2 Replies)
Discussion started by: Gajanad Bihani
2 Replies

9. Filesystems, Disks and Memory

cpu usage

hi, In response to your cpu usage answer I too read sys/sysinfo.h but , if we put these values to access the repective time fields in the array pst_cpu_time which is a member of the structure pst_dynamic values doesn't seem to match, why is like this? (0 Replies)
Discussion started by: sushaga
0 Replies

10. UNIX for Dummies Questions & Answers

CPU usage

What would I use to see the CPU usage of my process in Unix? (2 Replies)
Discussion started by: Karen
2 Replies
Login or Register to Ask a Question