root/gs2-extensions/parallel-building/trunk/src/bin/script/flush_caches.pl @ 27125

Revision 27125, 1.3 KB (checked in by jmt12, 7 years ago)

A script to try and flush all caches - I'm certain it's flushing disk cache, but some web postings suggest this flushes DNS cache too. I'm not convinced yet

  • Property svn:executable set to *
  • Property svn:mime-type set to application/x-perl
Line 
1#!/usr/bin/perl
2
3print "===== Flush DNS Cache =====\n";
4
5# The Premise: use sudoedit and other black magic to clear out the memory-
6# based disk cache (which is done by writing the number 3 to a certain
7# system file)
8print "   - Synching file system... ";
9`sync`;
10print "Done\n";
11print "   - Dropping memory disk cache... ";
12# - save our current default editor
13my $current_editor = $ENV{'EDITOR'};
14# - replace default editor with a script that simply clobbers the contents
15#   of any file it's handed with the number "3"
16$ENV{'EDITOR'} = 'reset_memcache_editor.sh';
17# - we now call sudoedit on the system file. How sudoedit works is that it
18#   starts by making a temp copy of the system file with appropriate
19#   permissions allowing the user to edit. It then passes the path to the
20#   temp file to the default editor - typically this would be an interactive
21#   editor like 'vi'. However, we've just replaced the editor with a custom
22#   script that just writes '3' as the content of the tmp file. Finally, when
23#   the editor exits, sudoedit copies the tmp file over the top of the system
24#   file, restoring appropriate root-level permissions
25`sudoedit /proc/sys/vm/drop_caches`;
26# - restore the default editor, just in case something in Greenstone
27#   depends on this being a reasonably value
28$ENV{'EDITOR'} = $current_editor;
29print "Done\n";
30
31print "Complete!\n\n";
32
33exit;
Note: See TracBrowser for help on using the browser.