User can create and modify files for only X days before they become read-only?

ChaosBlades

Contributor
Joined
Jul 4, 2015
Messages
137
Just ran into an issue where some files were modified with me knowing. Snapshots don't really work in this instance because I have to know something was changed in order to roll back before the snapshot is automatically deleted. Is there a way to have a user be able to write and modify files for only X amount of days before the files automatically become read-only? Having files automatically moved into a read-only dataset isn't really a possibility. They need to be able to be read by user2 as soon as user1 writes them.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
There's nothing built-in to FreeNAS or ZFS that would do this, but you should be able to script it easily enough with some creative use of the find command. Figure out the exact syntax, put it in a script, and set up a cron job to run it periodically. A first cut of the syntax would be something like find /path/to/files -type f -mtime +5 -exec chmod 400 {} (to keep ownership of the files the same, but change them to read-only, after five days).
 
Top