Logfile::Rotate error,
am 04.05.2006 05:29:19 von lancerset
Hello All,
I'm trying to use this Log::Rotate module but i am getting an error
messages when i try
to run this script. I dont know enough to know where the problem may
be.
############################
use Logfile::Rotate;
my $log = new Logfile::Rotate( File =>
'/usr/local/apache/logs/error_log',
Count => 7,
Gzip => 'lib',
Post => sub{
open(IN,
"/usr/local/apache/logs/httpd.pid");
kill("HUP", chomp()); }
Dir => '/var/log/old',
Flock => 'yes',
Persist => 'yes',
);
# process log file
$log->rotate();
############################
ERROR MESSAGE:
Can't modify in chomp at log_rotate_script02.pl line 9, near
")"
syntax error at log_rotate_script02.pl line 10, near "Dir"
Execution of log_rotate_script02.pl aborted due to compilation errors.
Any advice ?
Thanks,
Re: Logfile::Rotate error,
am 04.05.2006 07:24:45 von Sisyphus
"onlineviewer" wrote in message
news:1146713359.482640.51560@j73g2000cwa.googlegroups.com...
> Hello All,
>
> I'm trying to use this Log::Rotate module but i am getting an error
> messages when i try
> to run this script. I dont know enough to know where the problem may
> be.
>
> ############################
>
> use Logfile::Rotate;
> my $log = new Logfile::Rotate( File =>
> '/usr/local/apache/logs/error_log',
> Count => 7,
> Gzip => 'lib',
> Post => sub{
> open(IN,
> "/usr/local/apache/logs/httpd.pid");
> kill("HUP", chomp()); }
> Dir => '/var/log/old',
> Flock => 'yes',
> Persist => 'yes',
> );
>
> # process log file
>
> $log->rotate();
>
> ############################
>
Make that:
Post => sub{
open(IN,
"/usr/local/apache/logs/httpd.pid");
kill("HUP", chomp()); },
(ie add a comma at the end) and I think it will be fine. The way you've
written it there's no separation between the hash entry for 'Post' and the
hash entry for 'Dir'.
Cheers,
Rob
Re: Logfile::Rotate error,
am 04.05.2006 16:49:26 von lancerset
Hello Again,
I tried that out and i am gettting this message still:
Can't modify in chomp at log_rotate_module02.pl line 9, near
")"
Execution of log_rotate_module02.pl aborted due to compilation errors.
Re: Logfile::Rotate error,
am 04.05.2006 17:28:04 von lancerset
I've also tried this script, but no luck..
#####################################
use Logfile::Rotate;
my $log = new Logfile::Rotate( File =>
'/usr/local/apache/logs/error_log',
Count => 7,
Gzip => '/usr//bin/gzip',
Signal => sub {
my $pid = `cat
/usr/local/apache/logs/httpd.pid`;
my @args = ('kill', '-s',
'HUP', $pid );
system(@args);
},
Dir => '/var/log/old'
);
$log->rotate();
#####################################
Error Message:
Signal is a deprecated argument, see Pre/Post at log_rotate_module03.pl
line 12
/usr/bin/kill[8]: 431^J: Arguments must be %job or process ids.
Re: Logfile::Rotate error,
am 05.05.2006 03:55:55 von Sisyphus
"onlineviewer" wrote in message
news:1146754166.411693.248840@i39g2000cwa.googlegroups.com.. .
> Hello Again,
>
> I tried that out and i am gettting this message still:
>
> Can't modify in chomp at log_rotate_module02.pl line 9, near
> ")"
> Execution of log_rotate_module02.pl aborted due to compilation errors.
>
Oh yes - you can't do a 'chomp()'. (Sorry, missed that.)
One way is to code it as:
Post => sub{
open(IN, "/usr/local/apache/logs/httpd.pid") or die $!; # check that open
succeeded
my $t = ;
chomp($t);
kill("HUP", $t);
},
I don't use this module, btw, and know nothing about it - I'm just trying to
fix the errors based on the messages being generated. I don't know whether
that's going to make the script do whatever it is you're hoping it will do
:-)
Cheers,
Rob
Re: Logfile::Rotate error,
am 05.05.2006 20:17:35 von Jake Peavy
Sisyphus wrote:
> Oh yes - you can't do a 'chomp()'. (Sorry, missed that.)
>
> One way is to code it as:
>
> Post => sub{
> open(IN, "/usr/local/apache/logs/httpd.pid") or die $!; # check that open
> succeeded
> my $t = ;
> chomp($t);
> kill("HUP", $t);
> },
or: chomp( my $t = );
odd though, because he copied the example straight out of the docs...
-jp