Sometimes a script on your website/server might be causing some errors that you are unaware of. Some users might be seeing these errors under certain circumstances and others not. If users don’t report these errors, you won’t know unless you’re regularly checking your server logs. But no one likes to check server logs as part of their daily routine 🙂 So, here is a one-liner you can add to your crontab file:
0 2 * * * find / -mtime -1 -name "error_log" | mail -E -s "error_logs recently modified" firstname.lastname@example.org
The above line would automatically check your server daily at 2:00 am for any error_log files modified within the last 1 day (this is what the option
-mtime -1 above does). If any ones are found, you’ll get an email listing them — don’t forget to change the email address above to your email.