About Page
RM Safe

You won't notice this script until you really need it, and then it will be a life saver.

I used to have to download backups from a friends server, one day I downloaded 2 Gb (I had a quota of 3Gb) then deleted them from his server. Well thats what I thought, I typed the rm command in the wrong window, so I'd lost the backups and didn't have enough quota to get them again! It taught me to be more careful, for instance I now use different background colours for the terminals of my different servers, but it also prompted me to write these perl scripts which form the basis of rm safe.

Initially because of my losing 2Gb experience, the script put everything in one big partition with each user having their own directory within it. I've changed that as it could be utilised by dodgy users as a way of getting around quotas etc, now it puts it by default into each users ~/.recyle directory. It is also now up to users to clean up their own areas as they see fit, whereas that used to be done from a centralised cron job.

So using the script is simple enough, how I do it is make sure it is executable, place it in my path and alias rm to it (whilst I was getting used to it I aliased rms to it). So if you are using bash in your ~/.bashrc file:

	alias rm="rm_safe.pl"

And in your ~/.bash_profile

	export PATH=$PATH:/path/to/rm_safe/

To cleanup the old files, add a call to 'rm_safe.pl --clean_up=42' in your cron. Alternatively you can just run this manually every now and then when you need some space.

Pretty much every command also has a "--debug" option, so you can test things out without changing anything. It also has a --help option for more information. Good luck, let me know if you find any bugs or have any suggested improvements.

RM Safe Script

Back to Code

Cameron Green
Last Updated - Fri, 30 Jan 2015 07:04:48 -0600