Hello,
I need some help with the following script:
if ! [ -f ${APATH}/myfile.txt ];then
echo $(date +%Y%m%d"_"%H%M%S)": Nu am gasit fisierul ${APATH}/myfile.txt"
ps -fxu pin | grep "/usr/local/coreutils/bin/tail -f ${LOG_PATH}/x.log$" | awk '{system("kill "$2)}'
cat ${LOG_PATH}/x.log | sed -n -e '/LONG/{x;1!p;g;;}' -e h > ${APATH}/myfile.txt
/usr/local/coreutils/bin/tail -f ${LOG_PATH}/x.log | sed -n -e '/LONG/{x;1!p;g;;}' -e h >> ${APATH}/myfile.txt &
fi
date1=$(tail -1 ${PATH}/myfile.txt | cut -d" " -f2-5)
if [ -f exec_long.date ];then
date2=$(cat exec_long.date)
else
date2=$date1
echo $date1 > exec_long.date
fi
if ! [ "$date1" = "$date2" ];then
${CAL_PATH}/${APP_NAME}
sleep 1
echo $date1 > exec_long.date
fi
I have a continuously growing log file (x.log) in which i have to look for certain lines that contain "Long". The line above each line containing the word "Long" it contains a time stamp. I want to extract each line containing the time stamp into myfile.txt and check the difference between time stamps. Whenever there is a difference i need to run another script (${CAL_PATH}/${APP_NAME}), then sleep 1, then continue searching.
Lines with "Long" do not appear continuously, but in blasts. The script runs fine until the first pause encountered. Starting with the first pause, tail -f doesn't write in myfile.txt anymore.
Can someone help me understand why "tail -f" it stops writing into myfile.txt? Or does someone know an alternative to "tail -f" of achieving the initial scope of the script?
I'll appreciate any help.
Thanks!