MOON
Server: Apache
System: Linux vps.thepromohut.com 2.6.18-398.el5 #1 SMP Tue Sep 16 20:51:48 EDT 2014 i686
User: caretrak (507)
PHP: 5.2.10
Disabled: NONE
Upload Files
File: //scripts.20110601.041516.15411/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 );
    }
}