Solved

How to refresh cache for searching using grep?

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

705 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

15 Experts available now in Live!

Get 1:1 Help Now