diff --git a/scripts/loggernet_rotate.sh b/scripts/loggernet_rotate.sh index 20ca917bab7e8fb95bd57a83d031e87b0304909c..e3458fa4769c6e0df109681c33bda6ef217f9b14 100755 --- a/scripts/loggernet_rotate.sh +++ b/scripts/loggernet_rotate.sh @@ -52,7 +52,7 @@ EOF # specially handles 2400 which should go for the next day, not the past day yyyy_jjj_tower_split() { awk_command=' -NR>header_size { +(NR>header_size) && ($1 == "1") { time_spec = sprintf("%04d 01 %03d 00 00 00", $2, $3); epoch_seconds = mktime(time_spec); if ($4 == "2400") @@ -110,7 +110,12 @@ for file_suffix in $FILE_SUFFIXES; do yyyy_jjj_tower_split $input_file # copy the header back to the original file - cp $header_fn $input_file + if [ -s $header_fn ]; then + cp $header_fn $input_file + else + # loggernet doesn't like empty destination files + rm $input_file + fi # remove the temporary header file rm ${header_fn}