Compare different String in Log Files

Hi Guys , sorry for my first post but a newbie here need some help on my simple scripts.

I have some scripts below that count the job started and the job finished
and is the job started and job finished equal ..then all job was successfully run and
finished on that day.

but sometime the was started ..and for some reason it restarted again
and my job finished and job started were not equal that day.

On this case.. I want an output which Job was not been finished on that day.

so far the scripts only gave me a comparison between job been started and finished.

any good idea how I can do this? thanks in advance.
[im sorry dont know what will be the appropriate title for this]

Log Files

2012/02/16 00:35:18   Job : Activity Started : Job123
2012/02/16 00:37:16   Job : Activity Started : Job125
2012/02/16 00:38:12   Job : Activity Started : Job126
2012/02/16 00:40:11   Job : Activity Started : Job127
2012/02/16 00:45:21   Job : Activity Started : Job123 
2012/02/16 01:07:26   Job : Activity Finished : Job125
2012/02/16 01:08:42   Job : Activity Finished : Job126
2012/02/16 01:15:51   Job : Activity Finished : Job127

notice the Job123 did not finished on this log

Script

#!/bin/ksh
JobLog=/Log/server.log

STARTCount=`grep "Job : Activity Started:" ${JobLog} | wc -1`
ENDCount=`grep "Job : Activity Finished:" ${JobLog} | wc -1`

if [[ ${STARTCount} != ${ENDCount} ]] ; then
     echo "Job NOT Completed..Start:${STARTCount} End:${ENDCount}" >> /Log/unsuccessfull.log

else
     echo "Job has been Completed" >> /Log/successfull.log
fi

Try:

awk '/Started/{a[$8]++}/Finished/{a[$8]--}END{for (i in a) if (a>0) print i}' file

Hi,
Welcome to the unix forum.:slight_smile:
Try this one,

awk '{if(p[$NF] == 1){p[$NF]=0;}p[$NF]=1;info[$NF]=$0;}END{for(i in p){if(p == 1){print info >>unstopprocfile;}}' logfile

Cheers,
Ranga:-)

thanks mate this really works on my scripts

@rangarasan
thanks as well mate. I will try also your scripts with different approach on my program
hope to learn a lot from you here guys :b: