Solved

How to refresh cache for searching using grep?

Posted on 2014-12-15
5
288 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 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 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

840 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