Skip to content

Instantly share code, notes, and snippets.

@ejhayes
Created March 26, 2013 00:00
Show Gist options
  • Save ejhayes/5242024 to your computer and use it in GitHub Desktop.
Save ejhayes/5242024 to your computer and use it in GitHub Desktop.
#!/bin/bash
FAIL=0
LOG=log.txt
ERROR_LOG=messages.txt
GENERATORS=("FILE_1" "FILE_2")
echo "===> Truncating logs"
rm -f $LOG
rm -f *_$ERROR_LOG
# Generate the list of jobs to run
for i in "${GENERATORS[@]}"
do
(time php $i | sed 's/\([\x27\x22]\)/\\\1/g' | xargs -I output echo $i: output) >> $LOG 2>> $(basename $(dirname $i))_$(basename $i .php)_$ERROR_LOG &
done
# Get a summary of the jobs that are running
TASKS=`jobs`
# Tail the output
tail -f -n +0 log.txt &
tailpid=$!
# Wait for everything to stop running
for job in `jobs -p`
do
#echo "===> Starting Process: $job"
if [ "$job" != "$tailpid" ]; then
wait $job || let "FAIL+=1"
fi
done
# Summarize everything
echo "===> Killing Tail Process: $tailpid"
kill $tailpid
echo "=====> Process should be stopped: $tailpid"
echo "===> Removing log: $LOG"
rm -f $LOG
echo "===> Tasks Summary:"
echo "$TASKS"
for M in `ls *_$ERROR_LOG`
do
if [ "`cat $M | wc -l`" == "4" ]; then
echo "=====> TIMING INFORMATION: $M"
else
echo "=====> ERRORS FOUND WITH: $M"
fi
cat $M
done
if [ "$FAIL" == "0" ]; then
echo "===> NO ERRORS encountered"
else
echo "===> $FAIL ERRORS encountered"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment