I need to find and remove files older than 2 weeks from the home directories of my cluster. I do not want to let people just "touch" the file to change the modification date and keep it for another 2 weeks. (I'm talking about files of several hundreds of Gb) I thought about doing md5 check on the content and comparing it against a list with the file creation date, but maybe there is an easier solution.
Asked
Active
Viewed 93 times
0
-
You might be able to check creation date, but that does not show anything about modifications. – NiKiZe Nov 24 '21 at 10:12
-
Since linux does not keep track of the creation time, you might want to look for something like this : https://askubuntu.com/questions/470134/how-do-i-find-the-creation-time-of-a-file – Ror Nov 24 '21 at 11:08
-
@David, this can be very dangerous. You will remove (by your definition) users `.bashrc` files, ssh keys and so on. So add additional checks! – Romeo Ninov Nov 24 '21 at 12:19
-
Is the purpose of the deletion space savings, or something else? You can set quotas and let users work within those limits. – John Mahowald Nov 24 '21 at 14:52
-
@RomeoNinov do not worry, I would exclude certain directories :) – David Nov 29 '21 at 09:22
-
@JohnMahowald I cannot. Users need to work with huge files, I must allow them to do so, but they have to delete them in reasonable times. – David Nov 29 '21 at 09:25
1 Answers
0
You can remove files from the home directories with the following command :
find /home/*/ -mtime +15 -type f -delete
And easily put it in a cron to do it automatically.

Ror
- 321
- 3
- 16
-
2Was thinking the same, but then I read the whole question about users using `touch` – NiKiZe Nov 24 '21 at 10:13
-