#!/usr/bin/perl -wl use strict; use File::Find::Rule qw(find); sub readfile { open my $fh, shift or return ''; local $/; return readline $fh; } my @files = find 'file', name => 'status', in => '/proc'; # 33 is the Apache user's uid @files = grep readfile($_) =~ /^Uid:\s*33\b/m, @files; @files = grep readfile($_) =~ /^VmData:\s*(\d+)/m && $1 > 16384, @files; /(\d+)/ and print("Killing $1\n") and kill 15, $1 for @files; #### * * * * * perl /root/apachekill.pl 2>/dev/null