Where is my logfile of crontab?

I think on debian cron writes logs in /var/log/syslog.
If your system depends on rsyslogor syslogd you can check and uncomment either in /etc/rsyslog.conf or /etc/syslog.conf for line:

# cron.* /var/log/cron.log

and then restart services.

If your system depends on systemd for example you can check with following command:

journalctl _COMM=cron

or

journalctl _COMM=cron --since="date" --until="date"

For date format you can check journalctl.


By default the output from crontab jobs are sent to the local email address of the owning user. for example: The crontab output for aUser on host www.aDomain.com would be sent to [email protected]. The system uses its default mailer to accomplish the task.

You can divert this output to an alternate email address by adding a MAILTO statement within the crontab file. For example:

# Mail any output to [email protected], no matter whose crontab this is
[email protected]
# Run the following command ten minutes after midnight, every day
10 0 * * *       $HOME/bin/aJob.sh 

Be careful when using an external email address to receive crontab logs. Frequently sent messages may get caught in a spam filter. You would then have to mark the messages as Not Spam for services like Yahoo, HotMail, or Gmail.

An alternate solution would be to redirect the output of your crontab commands to a file of your choice. In the example below the stdout and stderr output is sent to /tmp/aJob.log. This method eliminates the possibility of an email message being sent.

# Run the following command ten minutes after midnight, every day
10 0 * * *       $HOME/bin/aJob.sh >> /tmp/aJob.log 2>&1

Another alternative is to send stderr logs to email and stdout logs to a file. In this case you get alerted by email when your crontab commands generate unexpected error messages. The difference with the previous example is that 2>&1 is removed to allow stderr output to go to the console and therefore to email.

# Mail any output to [email protected], no matter whose crontab this is
[email protected]    
# Run the following command ten minutes after midnight, every day
10 0 * * *       $HOME/bin/aJob.sh >> /tmp/aJob.log

Read more crontab tables and crontab command


Since this is not tagged debian and appears in fedora searches as well, here is how to check for recent (systemd-based) fedora:

sudo systemctl status crond

Typical output

● crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-09-29 16:09:21 CEST; 47min ago
 Main PID: 1167 (crond)
    Tasks: 1
   Memory: 2.8M
      CPU: 948ms
   CGroup: /system.slice/crond.service
           └─1167 /usr/sbin/crond -n

Sep 29 16:09:21 ncelrnd0216 systemd[1]: Started Command Scheduler.
Sep 29 16:09:21 ncelrnd0216 crond[1167]: (CRON) STARTUP (1.5.4)
Sep 29 16:09:21 ncelrnd0216 crond[1167]: (CRON) INFO (Syslog will be used instead of sendmail.)
Sep 29 16:09:21 ncelrnd0216 crond[1167]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 31% if used.)
Sep 29 16:09:21 ncelrnd0216 crond[1167]: (CRON) INFO (running with inotify support)

and all the logs with

journalctl --unit crond -n all

Tags:

Cron