This shows you the differences between two versions of the page.
cleanup_crazy_temp_files [2011/05/19 15:26] jt created |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Cleanup crazy temp files ====== | ||
- | <code perl> | ||
- | |||
- | #!/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; | ||
- | |||
- | } | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | </code> |