?
Solved

How to refresh cache for searching using grep?

Posted on 2014-12-15
5
Medium Priority
?
330 Views
Last Modified: 2014-12-15
I'm getting old results when I run grep.

It seems to me I remember something along the lines of grep using a cache I think? And that it needs to be refreshed for a fresh search.

Can you tell me how to do that? I'm on a linux/centos machine.
0
Comment
Question by:St_Aug_Beach_Bum
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40500378
"grep" itself doesn't have an own cache.
There is the usual filesystem cache in Unix/Linux, but you should never get old results after files have been modified, because the dirty cache pages are written to disk rather frequently!

Running "sync" forces writing of dirty pages to disk, so you can run

snyc

and retry.

To drop the whole filesystem cache you can run this (as root):

sync; echo 3 > /proc/sys/vm/drop_caches

This will not flush dirty objects, however.
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40500383
>I'm getting old results when I run grep.
An example please ;)  grep has no cache as said above already.
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 40501149
hmm, interesting...

What I was doing was searching for any instances in my wordpress sites for "FuncQueueObject", to check for any problems with this soaksoak.ru problem that's hitting wp sites..

I found one instance of it, replaced that file with a clean one. and ran the grep command again:

[root@jazz ~]# grep -Rl "FuncQueueObject" /home/                                        

I got back this:
                     
/home/mysite/public_html/wp-includes/template-loader.php
[root@jazz ~]#

Even though I had removed the infection from that file. Double checking it, "FuncQueueObject" isn't there... but grep says it is... that's why I was thinking there must be a cache.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 40501160
Even with a direct, non-recursive grep?

grep "FuncQueueObject" /home/mysite/public_html/wp-includes/template-loader.php

If the above finds it then it is actually there. That's certainly not a cache problem.

Maybe it's well there, but commented out?
To check this inspect the context:

grep -B 5 -A 5 "FuncQueueObject" /home/mysite/public_html/wp-includes/template-loader.php
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 40501608
Yep indeed, you're right - it was back. I had removed it but that didn't last long. I've removed it again and changed the permissions on that file to read only for all users. Hopefully that will do the trick.

Thanks for the help!
0

Featured Post

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question