How Can I Keep My Linux File Server Clean from System Files in Zip Archives?

0
13
Asked By TechieNinja42 On

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

Answered By LinuxWhisperer On

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!

Answered By SystemDude On

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!

Answered By SambaSleuth On

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.

Answered By CuriousCoder99 On

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!

Answered By AutoScriptMaster On

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.