#!/bin/sh
DATE="`date +'%Y-%m-%d'`"

# move the job files over a certain age
# maxdepth one ignores results/
for model in `ls /tmp/broker/` ; do
    if [ "$model" = "classify" ] ; then continue ; fi
    if [ "$model" = "conditioner" ] ; then continue ; fi
    mkdir -p /backup/$DATE/$model/
    /usr/bin/find /tmp/broker/$model -maxdepth 1 -type f \( -name "*.png" -o -name "*.json" \) -mmin +10 -exec mv {} /backup/$DATE/$model/ \; 2>/dev/null
done

# copy submit files to a specific location
cp -f /tmp/broker/submit/* /backup/submit/ 2>/dev/null

# Delete any remaining files
/usr/bin/find /tmp/broker/ -type f -name "*" -mmin +20 -delete


