A fresh mix of code snippets and tutorials

Monitor File Changes via Cron

Monitoring any changes made to your files is a super-useful security technique. Lots of applications, including forensics, diagnostics, and being cool. Here is a quick way to set it up directly via simple cron job.

Set up the following cron job to run once per day:

find /your/path/to/httpdocs -type f -ctime -1 -exec ls -ls {} \; | mail -E -s "File Monitor Report" email@example.com

Once defined, this will check for any changes made to any files contained in the root directory (whatever you specify for /your/path/to/httpdocs). It should be recursive, but may need some tweaking depending on your server setup. Any changes detected within the previous 24 hours will be sent via email to the specified address, email@example.com.

★ Pro Tip:

Banhammer ProBlackhole ProBBQ Pro