--- loncom/loncron	2002/05/11 21:18:14	1.26
+++ loncom/loncron	2002/06/08 14:59:04	1.30
@@ -55,9 +55,10 @@ ENDERROUT
 
 # ================================================================ Main Program
 
-# ------------------------------------------- Read access.conf and loncapa.conf
-my $perlvarref=LONCAPA::Configuration::read_conf('access.conf','loncapa.conf');
-my %perlvar=%{$perlvarref};
+# --------------------------------- Read loncapa_apache.conf and loncapa.conf
+my $perlvarref=LONCAPA::Configuration::read_conf('loncapa_apache.conf',
+                                                 'loncapa.conf');
+%perlvar=%{$perlvarref};
 undef $perlvarref;
 delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed
 delete $perlvar{'lonSqlAccess'}; # remove since sensitive and not needed
@@ -238,6 +239,7 @@ if ($psproc>250) { $notices++; }
 # --------------------------------------------------------------- clean out tmp
 print $fh '<hr><a name="tmp"><h2>Temporary Files</h2>';
 $cleaned=0;
+$old=0;
 while ($fname=<$perlvar{'lonDaemons'}/tmp/*>) {
                           my ($dev,$ino,$mode,$nlink,
                               $uid,$gid,$rdev,$size,
@@ -246,12 +248,24 @@ while ($fname=<$perlvar{'lonDaemons'}/tm
                           $now=time;
                           $since=$now-$mtime;
                           if ($since>$perlvar{'lonExpire'}) {
-                              $cleaned++;
-                              unlink("$fname");
+                              $line='';
+                              if (open(PROBE,$fname)) {
+				  $line=<PROBE>;
+                                  close(PROBE);
+			      }
+			      unless ($line=~/^CHECKOUTTOKEN\&/) {
+                                 $cleaned++;
+                                 unlink("$fname");
+			      } else {
+				  if ($since>100*$perlvar{'lonExpire'}) {
+                                     $cleaned++;
+                                     unlink("$fname");
+				 } else { $old++; }
+                              }
                           }
     
 }
-print $fh "Cleaned up ".$cleaned." files.";
+print $fh "Cleaned up ".$cleaned." files (".$old." old checkout tokens).";
 
 # ------------------------------------------------------------ clean out lonIDs
 print $fh '<hr><a name="tokens"><h2>Session Tokens</h2>';
@@ -338,20 +352,20 @@ if ($perlvar{'lonRole'} eq "library") {
 	$errors++;
 	         print $fh '<br><font color="red">Killall lonsql: '.
                     system('killall lonsql').' - ';
-                    sleep 60;
+                    sleep 2;
                     print $fh unlink($lonsqlfile).' - '.
                               system('killall -9 lonsql').
                     '</font><br>';
 	print $fh "<h3>lonsql not running, trying to start</h3>";
 	system(
  "$perlvar{'lonDaemons'}/lonsql 2>>$perlvar{'lonDaemons'}/logs/lonsql_errors");
-	sleep 10;
+	sleep 2;
 	if (-e $lonsqlfile) {
 	    print $fh "Seems like it started ...<p>";
 	    my $lfh=IO::File->new("$lonsqlfile");
 	    my $lonsqlpid=<$lfh>;
 	    chomp($lonsqlpid);
-	    sleep 30;
+	    sleep 2;
 	    if (kill 0 => $lonsqlpid) {
 		print $fh "<h3>lonsql at pid $lonsqlpid responding</h3>";
 	    } else {
@@ -360,7 +374,7 @@ if ($perlvar{'lonRole'} eq "library") {
 		print $fh "Give it one more try ...<p>";
 		system(
  "$perlvar{'lonDaemons'}/lonsql 2>>$perlvar{'lonDaemons'}/logs/lonsql_errors");
-		sleep 10;
+		sleep 2;
 	    }
 	} else {
 	    print $fh "Seems like that did not work!<p>";
@@ -435,19 +449,19 @@ if ($restartflag==1) {
    $errors++;
 	  print $fh '<br><font color="red">Killall lond: '.
                     system('killall lond').' - ';
-          sleep 60;
+          sleep 2;
           print $fh unlink($londfile).' - '.system('killall -9 lond').
                     '</font><br>';
    print $fh "<h3>lond not running, trying to start</h3>";
    system(
      "$perlvar{'lonDaemons'}/lond 2>>$perlvar{'lonDaemons'}/logs/lond_errors");
-   sleep 10;
+   sleep 2;
    if (-e $londfile) {
        print $fh "Seems like it started ...<p>";
        my $lfh=IO::File->new("$londfile");
        my $londpid=<$lfh>;
        chomp($londpid);
-       sleep 30;
+       sleep 2;
        if (kill 0 => $londpid) {
           print $fh "<h3>lond at pid $londpid responding</h3>";
        } else {
@@ -456,7 +470,7 @@ if ($restartflag==1) {
           print $fh "Give it one more try ...<p>";
 	  system(
  "$perlvar{'lonDaemons'}/lond 2>>$perlvar{'lonDaemons'}/logs/lond_errors");
-          sleep 10;
+          sleep 2;
        }
    } else {
        print $fh "Seems like that did not work!<p>";
@@ -531,19 +545,19 @@ if ($restartflag==1) {
    $errors++;
 	  print $fh '<br><font color="red">Killall lonc: '.
 	            system('killall lonc').' - ';
-          sleep 60;
+          sleep 2;
           print $fh unlink($loncfile).' - '.system('killall -9 lonc').
                     '</font><br>';
    print $fh "<h3>lonc not running, trying to start</h3>";
 	system(
  "$perlvar{'lonDaemons'}/lonc 2>>$perlvar{'lonDaemons'}/logs/lonc_errors");
-   sleep 10;
+   sleep 2;
    if (-e $loncfile) {
        print $fh "Seems like it started ...<p>";
        my $lfh=IO::File->new("$loncfile");
        my $loncpid=<$lfh>;
        chomp($loncpid);
-       sleep 30;
+       sleep 2;
        if (kill 0 => $loncpid) {
           print $fh "<h3>lonc at pid $loncpid responding</h3>";
        } else {
@@ -552,7 +566,7 @@ if ($restartflag==1) {
           print $fh "Give it one more try ...<p>";
  	  system(
  "$perlvar{'lonDaemons'}/lonc 2>>$perlvar{'lonDaemons'}/logs/lonc_errors");
-          sleep 10;
+          sleep 2;
        }
    } else {
        print $fh "Seems like that did not work!<p>";