I've got an Ubuntu 24.04 file server set up with an SMB share accessible by both Windows and Mac users. I'm wondering if there's a way to have Samba or another tool automatically clean up unwanted system files from Zip archives when they're copied to the share. Is it feasible to trigger a command like `zip -d your-archive.zip "__MACOSX*" DS_Store* Desktop.ini` whenever a Zip file is added, instead of running a constant cron job that scans all the Zips?
5 Answers
You might also want to consider using inotify-tools, which can monitor file changes in real-time. It's effective for these kinds of tasks!
Did you know systemd has a path unit type that monitors files for changes? It can trigger a script when a file is modified. Check out `man systemd.path` for details. I've used it to manage file versions and it works really well!
Absolutely, you could use incron instead of cron for this. I use it a lot on my servers, and it can be set to watch for specific file types. It should do the trick for your Zip files.
One option is teaching users to avoid including those system files from the get-go. If they don't feel the need to clean up because admins always handle it for them, they might not learn to do it right themselves. It's all about encouraging better habits!
Another tool is lsyncd, which can execute scripts when new files show up in a directory. Just be careful to prevent an infinite loop if you're modifying the Zip files!
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures