From 030de998afc53567b93efccf2327d81981eb380c Mon Sep 17 00:00:00 2001 From: davidh-ssec <david.hoese@ssec.wisc.edu> Date: Thu, 4 Jan 2018 14:16:59 -0600 Subject: [PATCH] Fix handling unexpected loggernet output --- scripts/loggernet_rotate.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/loggernet_rotate.sh b/scripts/loggernet_rotate.sh index 20ca917..e3458fa 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} -- GitLab