Question of the Week: How do I save cron job output to a file?
Emre ,
- Product
- Cronitor
- Sent from
- cronitor.io
- Sent
Emre, This week's question came from a developer who discovered that cron doesn't log the output or exit code from your cron jobs, only that they were started. How do I save cron job output to a file? It's a common practice for cron jobs to write important 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 the output of your cron job to a file, modify the crontab line to redirect your job's stdout and stderr to a file of your choice. Here is a simple before and after to show how you can add logging to a cron job: # Before $ crontab -l */5 * * * * python /home/crons/send-updates.py # After $ crontab -l */5 * * * * python /home/crons/send-updates.py >> /home/crons/send-updates.log 2>&1 Breaking this down, we are first using >>, the output redirection operator, which captures the output of the command to the left of it, and writes it to the log file that the arrow is point to. We give the full path to a log file, and then, at the end, the 2>&1 tells the shell that you want to combine any messages written to stderr with the messages written to stdout, so both are captured together in the same log. Note: In this case, we are using >> which will append to the log file. When a single arrow > is used, the log file will always be overwritten with the most recent result. If you are a CronitorCLI user, complete cron job output is automatically captured without any additional crontab changes. To view complete logs from any execution, select the job from your dashboard, find the execution in the Latest Activity panel, and click it to see the captured logs. View on the Web [https://cronitor.io/guides/how-to-save-cron-job-output] Cronitor Dashboard [https://cronitor.io/app] | Welcome to Cronitor [https://cronitor.io/app/welcome] You are receiving this email because you opted in to receive updates from Cronitor Cronitor, 1214 Parker Street, Berkeley, CA 94702 Unsubscribe [https://app.loops.so/unsubscribe/cmx2fomiwbo3j01ss29evfen7/384b0107a2b7fd66ed6c0591361a350e7c091ac0c97db18791b2fc0e1dfd7c466a66932522ce509b057ef949154b1af1434b742f245b26278ffa1ac6]
- Accession
- nse/cronitor/2026-11-29/7968
- From
- Cronitor · support@cronitor.io
- Sent
- 29 November 2026 · 22:00 UTC














