source: gs2-extensions/parallel-building/trunk/src/bin/script/flush_caches.pl@ 28648

Last change on this file since 28648 was 28648, checked in by jmt12, 10 years ago

Adding a short delay after writing to the flush_cache file just to ensure the system has settled down

  • Property svn:executable set to *
  • Property svn:mime-type set to text/plain
File size: 1.5 KB
RevLine 
[27125]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
[28648]31# - short break to give OS time to actually notice the drop_caches command
32print " - Waiting for command to complete... ";
33sleep(5);
34print "Done\n";
35
[27125]36print "Complete!\n\n";
37
38exit;
Note: See TracBrowser for help on using the repository browser.