I have an existing working shell script which will send an alert if the space exceeds 85% and but I have a new requirement where if the file size exceeds 85% then the older .csv files(location: /home/STAFF/ssk/Files) which are less than last 3 days should be deleted and I have to schedule this in a crontab. If possible please help me as I am new to Linux in appending that new condition in the existing script.
Below is the existing script.
sample.sh
:
#!/bin/bash
CURRENT=$(df /home/STAFF/ppal007/Files | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=85
if [ "$CURRENT" -gt "$THRESHOLD" ] ;
then
mail -s 'Disk Space Alert' abc@abc.com << EOF
Your free space is critically low in the location df /home/STAFF/ssk/Files. Used: $CURRENT%
EOF
fi