--- loncom/loncron 2024/07/28 23:52:11 1.103.2.16 +++ loncom/loncron 2024/10/24 22:24:26 1.103.2.17 @@ -2,7 +2,7 @@ # Housekeeping program, started by cron, loncontrol and loncron.pl # -# $Id: loncron,v 1.103.2.16 2024/07/28 23:52:11 raeburn Exp $ +# $Id: loncron,v 1.103.2.17 2024/10/24 22:24:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -307,7 +307,7 @@ sub log_machine_info { sub start_logging { my $fh=IO::File->new(">$statusdir/newstatus.html"); - my %simplestatus=(); + %simplestatus=(); my $now=time; my $date=localtime($now); @@ -968,11 +968,15 @@ sub log_simplestatus { rename("$statusdir/newstatus.html","$statusdir/index.html"); my $sfh=IO::File->new(">$statusdir/loncron_simple.txt"); - foreach (keys %simplestatus) { - print $sfh $_.'='.$simplestatus{$_}.'&'; + if (defined($sfh)) { + foreach my $key (keys(%simplestatus)) { + print $sfh $key.'='.$simplestatus{$key}.'&'; + } + print $sfh "\n"; + $sfh->close(); + } else { + print "Could not write to $statusdir/loncron_simple.txt\n"; } - print $sfh "\n"; - $sfh->close(); } sub write_loncaparevs { @@ -998,10 +1002,12 @@ sub write_loncaparevs { } } if ($output) { - if (open(my $fh,">$perlvar{'lonTabDir'}/loncaparevs.tab")) { + if (open(my $fh,'>',"$perlvar{'lonTabDir'}/loncaparevs.tab")) { print $fh $output; close($fh); &Apache::lonnet::load_loncaparevs(); + } else { + print "Could not write to $perlvar{'lonTabDir'}/loncaparevs.tab\n"; } } return; @@ -1034,10 +1040,12 @@ sub write_serverhomeIDs { } } if ($output) { - if (open(my $fh,">$perlvar{'lonTabDir'}/serverhomeIDs.tab")) { + if (open(my $fh,'>',"$perlvar{'lonTabDir'}/serverhomeIDs.tab")) { print $fh $output; close($fh); &Apache::lonnet::load_serverhomeIDs(); + } else { + print "Could not write to $perlvar{'lonTabDir'}/serverhomeIDs.tab\n"; } } return; @@ -1098,6 +1106,8 @@ sub write_hostips { } close($fh); chmod(0644,$newfile); + } else { + print "Could not write to $lontabdir/currhostips.tab\n"; } } if (keys(%prevhosts) && keys(%currhosts)) { @@ -1123,6 +1133,8 @@ sub write_hostips { } print $fh "\n*******************\n\n"; close($fh); + } else { + print "Could not write to $perlvar{'lonDaemons'}/logs/hostip.log\n"; } my $emailto = &Apache::loncommon::build_recipient_list(undef, 'hostipmail',$defdom); @@ -1438,7 +1450,7 @@ sub send_mail { "Subject: ".$subj."\n". "Content-type: text/html\; charset=UTF-8\n". "MIME-Version: 1.0\n\n"; - if (open(my $fh,"<$statusdir/index.html")) { + if (open(my $fh,'<',"$statusdir/index.html")) { while (<$fh>) { $loncronmail .= $_; } @@ -1554,7 +1566,7 @@ sub main () { my $now = time; my $tmpfile = $perlvar{'lonDaemons'}.'/tmp/lciptables_iphost_'. $now.$$.int(rand(10000)); - if (open(my $fh,">$tmpfile")) { + if (open(my $fh,'>',"$tmpfile")) { my %iphosts = &Apache::lonnet::get_iphost(); foreach my $key (keys(%iphosts)) { print $fh "$key\n";