Restart script based on MD5sum

Ok, I run a small script, that restarts a perl script when it fails (it's a very unreliable perl script, but I can't change it, it's crucial, and I don't know perl)
It outputs data into a logfile. Unfortunately, it also regularly hangs. This is a major problem because if it hangs, no data is written to the logfile (which is parsed by a python script). So, what I want to do, is to MD5sum the logfile every 30 seconds, and if the md5sum is the same as the md5sum the half minute before, to restart the script. How might I do this?

In Korn...

while true
do
chksum1=`sum <logfile>`
sleep 30
chksum2=`sum <logfile>`
if [ $chksum1 = $chksum2 ]
then
bounce Perl script
fi
done

HTH

Jerry

I tried this in Korn, and got:

./checksumtester[10]: [: (path to log):unknown operator

I had the same result when I tried it in Dash as well.

by the way, line 10 is:
if [ $chksum1 = $chksum2 ]

Have you used single quotes (') instead of backquotes (`) in the "chksum=" lines?

Also, you may want to use...

if [ "$chksum1" = "$chksum2" ]

for correctness and also to protect against embedded spaces in chksum1 and 2.

I'd actually just copied what you wrote.

It was the "$chksum1" quotes that fixed it. Thanks!