]> git.pld-linux.org Git - packages/apache1-mod_bandwidth.git/blame - apache1-mod_bandwidth-cleanlink.pl
- use apache1(EAPI) for runtime dep
[packages/apache1-mod_bandwidth.git] / apache1-mod_bandwidth-cleanlink.pl
CommitLineData
babca24e
AM
1#!/usr/bin/perl
2
3#
4# A little daemon that I use to clean links created by the bandwidth
5# module for Apache when they weren't removed properly by the server.
6# (Ie: when a httpd process didn't terminated in the usual way.)
7#
8# Change the value of TIME to how often (in seconds) you want to
9# do the cleaning.
10#
11
12$TIME=120;
13
afe4359d 14$PS="ps auxw";
babca24e
AM
15$LINKDIR="/var/run/apache-mod_bandwidth/link";
16
babca24e
AM
17
18sub do_clean {
19 local(%ppid);
20
21 open(INP, "$PS |");
22 while(<INP>) {
23 if (($process) =/^\S+\s+(\d+)\s+.+httpd\s/) {
24 $ppid{$process}=1;
25 }
26 }
27 close(INP);
28
29 opendir(DIR, $LINKDIR);
30 local(@filename)=readdir(DIR);
31 closedir(DIR);
32
33 for($i=0; $i <= $#filename; $i++) {
34 if ($filename[$i] =~ /^\d+$/) {
35 if (! $ppid{$filename[$i]}) {
36 unlink("$LINKDIR/$filename[$i]");
37 }
38 }
39 }
40}
207461cd
MP
41
42do_clean();
43
This page took 0.064733 seconds and 4 git commands to generate.