Lsyncd wrapper

usage: lsyncdwrap </path/to/status/file> <command> <command_options>

#!/bin/sh

STATFILE=$1
shift
CMDLINE=$@

if [ -s $STATFILE ]; then
	exit 0
fi

START=`date +%s`
$CMDLINE >> $STATFILE 2>&1
ERR=$?
END=`date +%s`
DIFF=$(($END - $START))

# append to STATFILE
if [ $ERR -ne 0 ]; then
        echo "### ERROR: `date` ### TIME [$DIFF] - ARGS: $@" >> $STATFILE
else
	echo -n "" > $STATFILE
fi

exit 0