How to save cron job output to a log file

By: Shane Harter|Last Updated: Oct 09, 2026

By default, cron doesn't log the output or exit code from your cron jobs, only that they were started. This guide covers a simple way to save that output in a file.

Cron records the start in syslog. The files are listed in Where are cron logs stored?.

Logging the output of a cron job

It's a common practice for cron jobs to write debugging and verification details to stdout and stderr, usually with print or echo statements from within the code. This is the text you see in your terminal when you run the job from the command line. To save it, redirect both streams on the crontab line:

# Before
*/5 * * * * python /home/crons/send-updates.py

# After
*/5 * * * * python /home/crons/send-updates.py >> /home/crons/send-updates.log 2>&1

>> appends stdout to the file the arrow points at. A single > truncates that file on every run. 2>&1 has to come after the file redirect. It sends stderr to the same place as stdout. The other order, 2>&1 >> /home/crons/send-updates.log, leaves stderr on cron's mail pipe and only stdout reaches the file.

The directory has to exist already, and the crontab's user has to be able to create or append the file. Cron will not create /home/crons for you. If the redirect fails, that error becomes the job's output, which cron then tries to mail. With no mailer, the attempt shows up as No MTA installed, discarding output.

Output in Cronitor

cronitor exec sends the command's stdout and stderr to Cronitor when the job finishes. It also sends the command string, arguments included. --no-stdout stops the output upload only. The command string is still sent, so do not put passwords, tokens, or other secrets in the arguments. cronitor sync adds the wrapper to the crontab line. You do not need the redirect just to read the log in Cronitor. Open the job and click the run under Latest Activity. The row expands to the log text. A long log also has a Full Log Output link.

If the output itself may contain secrets or customer data, pass --no-stdout before the monitor key. The local redirect can stay:

*/5 * * * * cronitor exec --no-stdout monitor-key python /home/crons/send-updates.py >> /home/crons/send-updates.log 2>&1

That flag has to sit between exec and the monitor key. After the key, --no-stdout is just another argument to your command. See Wrap an executable without uploading its output for what is uploaded. Schedules and alerts are in job monitoring.

Want alerts if your cron jobs stop working?

Monitor your cron jobs with Cronitor to easily collect output, capture errors and alert you when something goes wrong.