I have run multiple crontabs on my Linux system for regular tasks like backups, data processing, etc. Each time the cron job run sends a new email to me. Also, there are some wget commands configured in crontab which is creating a huge number of files under the home directory.
Suppress Cronjob Output and Logs
You can easily suppress the output of any cronjob by redirecting output to /dev/null. You can do this by appending >/dev/null 2>&1 to cronjob, for which you want to suppress output.
The >/dev/null tells the cron to send all output (STDOUT) to /dev/null The 2>@1 tells the cron to send all errors (STDERR) to same as (STDOUT)
This is more useful for the cron jobs running wget command. I have a cron job with wget run every minute. Which creates a new file each time wget runs with crontab under the home directory. So I configured it as below and now my home is clean.
Using MAILTO Option
You can disable the email notification for cronjob by setting MAILTO=””. You can also set the same variable to some other email to send an email specified from the specific job. Thank you for reading this tutorial. You may also like our tutorial Crontab in Linux with 20 useful examples for scheduling cron jobs.