File: //proc/self/root/scripts.20110531.215904.25158/purge_old_config_caches
#!/usr/bin/perl
# cpanel - purge_old_config_caches Copyright(c) 2009 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cpanel license. Unauthorized copying is prohibited
#
# This script removes any caches in /var/cpanel/configs.cache that are older then 7 days
#
my $TTL = ( 86400 * 7 ); # 7 days
my $now = time();
if ( !-d '/var/cpanel/configs.cache' ) {
mkdir( '/var/cpanel/configs.cache', 0700 ) || die;
exit; # Nothing in directory to purge, just bail
}
opendir my $cachefile_dir, '/var/cpanel/configs.cache';
my @cache_files = readdir $cachefile_dir;
closedir $cachefile_dir;
foreach my $cache_file (@cache_files) {
if ( ( stat( '/var/cpanel/configs.cache/' . $cache_file ) )[9] + $TTL < $now ) {
unlink( '/var/cpanel/configs.cache/' . $cache_file );
}
}