kuda.ai

Thoughts on programming and music theory.

dark mode

How to log cron job outputs

Created on March 31, 2026 Updated on April 20, 2026

linux

This works on Ubuntu.

There are two layers to this problem:

  1. see meta logs of cron
  2. see the actual logs of the job

meta logs:

# either: /var/log/syslog
sudo grep 'CRON' /var/log/syslog | tail -10

# or alternatively: journalctl
journalctl -u cron

This will tell you that the scheduled cron job ran. It will not log anything from the command that ran.

Example:

2026-04-20T10:06:01.341918+02:00 mylinux CRON[300139]: (davidkuda) CMD (date >> /home/davidkuda/cron.log)

job logs:

You need to use redirection of STDOUT and STDERR. >> ~/logs/job.log 2>&1

Example:

* * * * * date >> /home/davidkuda/cron.log 2>&1

What is the arcane 2&1?

There is a very good explanation of this on StackOverflow.