Score:0

Removing old files from home directories

mz flag

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.

in flag
You might be able to check creation date, but that does not show anything about modifications.
Ror avatar
om flag
Ror
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
Romeo Ninov avatar
in flag
@David, this can be very dangerous. You will remove (by your definition) users `.bashrc` files, ssh keys and so on. So add additional checks!
John Mahowald avatar
cn flag
Is the purpose of the deletion space savings, or something else? You can set quotas and let users work within those limits.
mz flag
@RomeoNinov do not worry, I would exclude certain directories :)
mz flag
@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.
Score:0
om flag
Ror

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.

in flag
Was thinking the same, but then I read the whole question about users using `touch`
mz flag
Exactly, this won't work for me :/
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.