[LON-CAPA-cvs] cvs: loncom / loncron
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Fri, 13 Apr 2007 18:26:25 -0000
albertel Fri Apr 13 14:26:25 2007 EDT
Modified files:
/loncom loncron
Log:
- bug#5199 rotate more log files
Index: loncom/loncron
diff -u loncom/loncron:1.72 loncom/loncron:1.73
--- loncom/loncron:1.72 Wed Apr 11 19:08:43 2007
+++ loncom/loncron Fri Apr 13 14:26:22 2007
@@ -2,7 +2,7 @@
# Housekeeping program, started by cron, loncontrol and loncron.pl
#
-# $Id: loncron,v 1.72 2007/04/11 23:08:43 albertel Exp $
+# $Id: loncron,v 1.73 2007/04/13 18:26:22 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -62,6 +62,17 @@
ENDERROUT
}
+sub rotate_logfile {
+ my ($file,$fh,$description) = @_;
+ my $size=(stat($file))[7];
+ if ($size>40000) {
+ &log($fh,"<p>Rotating $description ...</p>");
+ rename("$file.2","$file.3");
+ rename("$file.1","$file.2");
+ rename("$file","$file.1");
+ }
+}
+
sub start_daemon {
my ($fh,$daemon,$pidfile,$args) = @_;
my $progname=$daemon;
@@ -69,13 +80,8 @@
$progname='loncnew';
}
my $error_fname="$perlvar{'lonDaemons'}/logs/${daemon}_errors";
- my $size=(stat($error_fname))[7];
- if ($size>40000) {
- &log($fh,"<p>Rotating error logs ...</p>");
- rename("$error_fname.2","$error_fname.3");
- rename("$error_fname.1","$error_fname.2");
- rename("$error_fname","$error_fname.1");
- }
+ &rotate_logfile($error_fname,$fh,'error logs');
+
system("$perlvar{'lonDaemons'}/$progname 2>$perlvar{'lonDaemons'}/logs/${daemon}_errors");
sleep 1;
if (-e $pidfile) {
@@ -193,18 +199,7 @@
}
my $fname="$perlvar{'lonDaemons'}/logs/$daemon.log";
-
- my ($dev,$ino,$mode,$nlink,
- $uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,
- $blksize,$blocks)=stat($fname);
-
- if ($size>$maxsize) {
- &log($fh,"<p>Rotating logs ...</p>");
- rename("$fname.2","$fname.3");
- rename("$fname.1","$fname.2");
- rename("$fname","$fname.1");
- }
+ &rotate_logfile($fname,$fh,'logs');
&errout($fh);
return $result;
@@ -450,23 +445,22 @@
} else { &log($fh,"No perm log\n") }
my $fname="$perlvar{'lonDaemons'}/logs/lonnet.log";
-
- my ($dev,$ino,$mode,$nlink,
- $uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,
- $blksize,$blocks)=stat($fname);
-
- if ($size>40000) {
- &log($fh,"<p>Rotating logs ...</p>");
- rename("$fname.2","$fname.3");
- rename("$fname.1","$fname.2");
- rename("$fname","$fname.1");
- }
+ &rotate_logfile($fname,$fh,'lonnet log');
&log($fh,"</pre>");
&errout($fh);
}
+sub rotate_other_logs {
+ my ($fh) = @_;
+ my $fname="$perlvar{'lonDaemons'}/logs/autoenroll.log";
+ &rotate_logfile($fname,$fh,'Auto Enroll log');
+ $fname="$perlvar{'lonDaemons'}/logs/autocreate.log";
+ &rotate_logfile($fname,$fh,'Create Course log');
+ $fname="$perlvar{'lonDaemons'}/logs/searchcat.log";
+ &rotate_logfile($fname,$fh,'Search Cataloguing log');
+}
+
# ----------------------------------------------------------------- Connections
sub test_connections {
my ($fh)=@_;
@@ -565,7 +559,7 @@
}
sub log_simplestatus {
- rename ("$statusdir/newstatus.html","$statusdir/index.html");
+ rename("$statusdir/newstatus.html","$statusdir/index.html");
my $sfh=IO::File->new(">$statusdir/loncron_simple.txt");
foreach (keys %simplestatus) {
@@ -676,6 +670,7 @@
&clean_lonIDs($fh);
&check_httpd_logs($fh);
&rotate_lonnet_logs($fh);
+ &rotate_other_logs($fh);
}
if (!$justcheckconnections && !$justreload) {
&checkon_daemon($fh,'lonsql',200000);