A common problem for many users, is having files auto-purged from scratch before they've had a chance to identify and move those files to home or research spaces. This method uses a simple script to identify files that are approaching the auto-purge deadline, combined with a user cron job. The script emails the user at a designated interval with a list of files that are within a time window specified by the user.
The following script will check the timestamps on all files within the directory specified and output those that are over a specified number of days old (with respect to ctime and mtime). The list of files produced is then sent to the user via email:
Save this script along with any modifications (minimally the email address, directory path, and the number of days you want to use), and set the execution bits:
Setup User Crontab
Now we need to setup a user cron job to run this script at the desired interval (daily, weekly, etc.). To do this, we need to select a dev-node and create a crontab file:
The "crontab -e" command will open an empty file using "vi" which will become your crontab for that dev-node. At this point, you can add directives on when the script should be run:
In this example, my script will run from "~/bin" at 4:00 am every day (you really only need the very last line shown above, the rest is mostly for information).
When you are done editing your crontab, save it and then check it:
Here's what I get in my inbox when my scratch check script runs: