Disable cron emails (solution)

Originally published at: Disable cron emails (solution)

This article lists three common methods to disable cron emails and another solution to send emails only when errors occur. Cron is a daemon that executes scheduled commands. More specifically, the software utility cron is a time-based job scheduler for Unix-like operating systems like Linux. You can use cron to set up jobs to run…

couldn’t you use cron -L and follow the instructions in crontab (1 & 5) man pages?
And Debian uses it’s own version , See cron (8) man page “Debian Specific” section:
DEBIAN SPECIFIC
Debian introduces some changes to cron that were not originally avail-
able upstream. The most significant changes introduced are:

   —      Support    for    /etc/cron.{hourly,daily,weekly,monthly}    via
          /etc/crontab,

   —      Support for /etc/cron.d (drop-in dir for package crontabs),

   —      PAM support,

   —      SELinux support,

   —      auditlog support,

   —      DST and other time-related changes/fixes,

   —      SGID crontab(1) instead of SUID root,

   —      Debian-specific file locations and commands,

   —      Debian-specific configuration (/etc/default/cron),

   —      numerous other smaller features and fixes.

   Support  for  /etc/cron.hourly,  /etc/cron.daily,  /etc/cron.weekly and
   /etc/cron.monthly is provided in Debian through the default setting  of
   the /etc/crontab file (see the system-wide example in crontab(5)).  The
   default system-wide crontab contains four tasks: run every hour,  every
   day, every week and every month.  Each of these tasks will execute run-
   parts providing each one of the  directories  as  an  argument.   These
   tasks are disabled if anacron is installed (except for the hourly task)
   to prevent conflicts between both daemons.

   As described above, the files under these directories have to pass some
   sanity checks including the following: be executable, be owned by root,
   not be writable by group or other and,  if  symlinks,  point  to  files
   owned  by root.  Additionally, the file names must conform to the file-
   name requirements of run-parts: they must be entirely made up  of  let-
   ters,  digits  and can only contain the special signs underscores ('_')
   and hyphens ('-').  Any file that does not conform  to  these  require-
   ments  will  not  be executed by run-parts.  For example, any file con-
   taining dots will be ignored.  This is done to prevent cron  from  run-
   ning  any  of  the files that are left by the Debian package management
   system when handling files in /etc/cron.d/ as configuration files (i.e.
   files ending in .dpkg-dist, .dpkg-orig, .dpkg-old, and .dpkg-new).

   This  feature  can be used by system administrators and packages to in-
   clude tasks that will be run at defined intervals.   Files  created  by
   packages  in  these  directories should be named after the package that
   supplies them.

   Support for /etc/cron.d is included in the cron  daemon  itself,  which
   handles this location as the system-wide crontab spool.  This directory
   can contain any file  defining  tasks  following  the  format  used  in
   /etc/crontab, i.e. unlike the user cron spool, these files must provide
   the username to run the task as in the task definition.

   Files in this directory have to be owned by root, do not need to be ex-
   ecutable  (they  are  configuration  files, just like /etc/crontab) and
   must conform to the same naming convention as used  by  run-parts(8)  :
   they  must consist solely of upper- and lower-case letters, digits, un-
   derscores, and hyphens.  This means that they cannot contain any  dots.
   If the -l option is specified to cron (this option can be setup through
   /etc/default/cron, see below), then they must conform to the LSB  name-
   space  specification,  exactly  as  in  the --lsbsysinit option in run-
   parts.

   The intended purpose of this feature is to allow packages that  require
   finer      control      of      their      scheduling      than     the
   /etc/cron.{hourly,daily,weekly,monthly} directories to  add  a  crontab
   file to /etc/cron.d.  Such files should be named after the package that
   supplies them.
1 Like

Thanks for sharing this @tmick

1 Like