I have a cron job that writes logs to
/tmp. I want to automatically delete the oldest files when the free space in the disk becomes less than 1GB.
I'm trying to do
df -ah /tmp, then take the 2nd line, use
cut to get the
avail column. Then in a
for loop, keep deleting the files older than n days with
-mtime until there's enough free space.
I probably want to set this up as a cron job that runs daily as well.