Vema wrote:
>
> "AHDXAPI Server is now started running Thu Sep 11 23:51:00 2003"
>
> The above message is getting registerd in the log file
> my script i had schedule it for every minute thru crontab
> after a minute the following is getting update in my log file
>
> AHD XAPI SERver Running with Process ID '18383' On Thu Sep 11 23:53:00 2003
>
>
> but what i want is to append the contents of the log file like
>
> how can i achive this
> AHDXAPI Server is now started running Thu Sep 11 23:51:00 2003
> AHD XAPI SERver Running with Process ID '18383' On Thu Sep 11 23:53:00 2003
>
>
> *******************************************************************************************
> #!/proj/ahd02/CAisd/ActivePerl-5.6.0.618/bin/perl
> #/usr/local/bin/perl
> use strict;
> use warnings;
> use POSIX qw(strftime);
> my $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
> my $xapipgm = "/proj/ahd02/CAisd/site/mods/scripts/srvtst26.pl";
> my $ret = qx(pgrep -f srvtst26);
> if ($? eq 0){
> my $ret = qx(pgrep -f $xapipgm);
> # $proc= qx(ps -e|grep svrtst26);
> print "AHD XAPI SERver Running with Process ID '$ret' On $now_string";
> }
> else{
> open (LOG,">>/proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init.log") ||
> Error('open', 'file');
> print LOG "AHDXAPI Server is now started running $now_string";
> close (LOG);
> my $ret = qx(perl $xapipgm
> >>/proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init.log);
> }
> *****************************************************************************************
Hi Vema.
I'm not clear whether this script is 'srvtst26.pl' or another separate
Perl script.
This might work for you.
I hope it helps,
Rob
#!/proj/ahd02/CAisd/ActivePerl-5.6.0.618/bin/perl
#/usr/local/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);
my $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
my $xapipgm = '/proj/ahd02/CAisd/site/mods/scripts/srvtst26.pl';
my $logfile = '/proj/ahd02/CAisd/site/mods/scripts/log/init/ahdxapi.init.log';
open LOG, '>>', $logfile or Error('open', 'file');
my $ret = qx(pgrep -f srvtst26);
if ($? == 0) {
print LOG "AHD XAPI SERver Running with Process ID '$ret' On $now_string";
}
else{
print LOG "AHDXAPI Server is now started running $now_string";
$ret = qx(perl $xapipgm >> $logfile);
}
close LOG;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]