July 7, 201411 yr Is there a way to have a folder watched and files auto deleted after a set amount of time? I download and watch tv shows, but once I've watched them I'm threw. From RarFlix on Roku I always had a delete button under the files, but since I've moved to unraid server from windows 7 the button is no longer there. I could set say 30 days for a file, after the 30 days the file will automatically be deleted.
July 7, 201411 yr You can have a play around with; find /mnt/user/Download -atime +30 -type f -exec ls -l {} \; and see if thats returning what you think it should. The 'atime' parameter is access time, so could be you watching the file, or any system process or application accessing the file to read metadata etc, so mightnt be terribly accurate unfortunately. The 'not deleting unless watched' stipulation might be tricky depending on your setup Once you've gotten the command down, and you're 100% happy with it, you can change the exec in it from calling ls to rm, and put it into crontab to run automatically on a schedule
July 7, 201411 yr Author Thx Kal, didn't seem to do anything though I don't understand all of the switches as to what I need to adjust. I've got -atime, but what about the others. is one of these marking 'not deleting unless watched'? Sorry for all of the questions, i'm new to linux, been a windows user for ever. Windows spoils us, and then wants to control EVERYTHING.
July 7, 201411 yr no worries - im no great shakes at it either, so anyone else, feel free to chime in with other ideas, corrections etc So from your post it sounds like it came back with nothing? Have you the directory set as needed? Are there files in that directory that you think should be listing - ie files you last accessed more then 30 days ago? unfortunately, theres not much there to adjust, and might be hitting the limitation of the atime parameter find <directory> fairly self explanatory -atime +30 last access time greater then 30 days ago. -30, would be less then 30 days ago. Just '30' would be exactly 30 days ago -type f only interested in files, as opposed to 'd' for directories -exec ls -l {} \; for every file matching previous criteria, execute the command 'ls -l' against it - so list it. The limitation of the atime parameter, is that loads of stuff can access the files - from automated processes (parity check), to scheduled tasks, to your actual watching of the files (the only one we're interested in). So it can fall down at this point.. If there was someway to mark a file as being watched, in such a way that it could be then polled from the command line, that would help things, but Im not too sure if there is such a way. I know in work we marked files with the 'archive' attribute after a backup, so once files are older then x days, and have the archive attribute, they get automatically deleted. But I dont know if such a solution is possible for you Other option you could do, is just an arbitrary 'delete files in this folder older then X' - ignoring watched status. For that I'd double the retention period, just to be sure you dont delete before managing to watch them. Instead of 'atime', we'd use modified time 'mtime' for it
Archived
This topic is now archived and is closed to further replies.