Automatically be notified of any errors on your server

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" yourmail@server.com

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.

Published by Genedy

I'm the founder of BigProf Software. We're a tiny team of developers who create tools that make it easy (and affordable) for anyone to create connected business applications that work from any device with a browser.

Leave a comment

Your email address will not be published. Required fields are marked *