# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
55 * * * * root /root/cleanspace/cleanspace.sh
0 3 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
10 3 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
20 3 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#


#!/bin/sh

# This script removes oldest directory found in catalog if the disk is more than 90 percent full
# The script is intended to run about one time every hour

catalog="/nfs/SecurityCam"

touch /tmp/securitycam

echo "Disk space: "`df $catalog | tail -1 | sed 's/%//g' | awk '{print $5}'`"%"
for i in $(df $catalog | tail -1 | sed 's/%//g' | awk '$5 >= 90 {print $5}'); do
ls -t $catalog | tail -1 | xargs -iarg bash -c "echo 'will delete $catalog/arg in 5 seconds'";
sleep 5
echo "deleting..."
ls -t $catalog | tail -1 | xargs -iarg bash -c "rm -rf $catalog/arg; echo 'deleted arg'";
done