Solved

How to refresh cache for searching using grep?

Posted on 2014-12-15
5
270 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
  • 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 37

Expert Comment

by:Gerwin Jansen
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 500 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now