User Tools

Site Tools


cleanup_crazy_temp_files

This is an old revision of the document!


Cleanup crazy temp files

#!/bin/env perl
# name: clean-magick-tmp
# date: 20110515
# author: jason thomas <jason@lithiumfox.com>
# purpose: check tmp dir for pesky image magick tmp files that are larger then 3gb
 
use strict;
my $maxsize = '3000000000';
my $tmpdir = '/tmp';
opendir (TMPDIR, $tmpdir); 
my @tmpfiles = readdir(TMPDIR);
close (TMPDIR);
 
	foreach (@tmpfiles){
		my $pathtotmp = "$tmpdir/$_";
		if ($pathtotmp =~ m/^\/tmp\/magick-\w+/g){
 
		if (-s $pathtotmp >= $maxsize){
			open (FH, "<$pathtotmp");
				if(tell(FH) != -1){
					print "$pathtotmp is big \n";
					unlink $pathtotmp;
 
				}
			}
		}
	}
cleanup_crazy_temp_files.1305818783.txt.gz ยท Last modified: 2020/08/10 02:28 (external edit)