X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=bin%2Fcleantmp.pl;h=4b42cbe955bd0ab4cd679cba5d4f24944ee5891f;hb=89be03cdf0fd811112da15b47d710f7bc3a00e74;hp=c7b1b19d5b30f7d856da560022751d64facd524f;hpb=7e0b880ba9c56cfa877b4b6bf3d190b0ff027bdf;p=clearscm.git diff --git a/bin/cleantmp.pl b/bin/cleantmp.pl index c7b1b19..4b42cbe 100755 --- a/bin/cleantmp.pl +++ b/bin/cleantmp.pl @@ -46,6 +46,8 @@ $Date: $ -c|onf : Config file holding patterns to match (Default: .../etc/cleantmp.conf) -l|ogpath : Path to logfile (Default: /var/log) + -a|ppend: Append to logfile (Default: Noappend) + -da|emon Run in daemon mode (Default: -daemon) -s|leep : How many seconds to sleep between polls (Default: 60) =head1 DESCRIPTION @@ -80,6 +82,7 @@ my %opts = ( help => sub { pod2usage(-verbose => 2)}, verbose => sub { set_verbose }, debug => sub { set_debug }, + daemon => 1, tmp => File::Spec->tmpdir(), conf => "$FindBin::Bin/../etc/$script.conf", logpath => '/var/local/log', @@ -161,13 +164,19 @@ GetOptions ( 'help', 'verbose', 'debug', + 'daemon!', 'tmp=s', 'logpath=s', 'conf=s', - 'sleep=i' + 'sleep=i', + 'append', ) or pod2usage; -$log = Logger->new(path => $opts{logpath}, timestamped => 1); +$log = Logger->new( + path => $opts{logpath}, + timestamped => 1, + append => $opts{append}, +); $log->msg("Starting $FindBin::Script"); @@ -186,7 +195,12 @@ $monitor->watch({ set_debug if $DB::OUT; -EnterDaemonMode unless $DB::OUT or get_debug; +if ($opts{daemon}) { + # Perl complains if we reference $DB::OUT only once + no warnings; + EnterDaemonMode unless defined $DB::OUT or get_debug; + use warnings; +} # if while () { $monitor->scan;