Problem Statement
How do you log the output of cron jobs for debugging?
Explanation
Redirect both standard output and error streams to a log file in the cron entry.
This ensures any issues during execution are captured for analysis.
Code Solution
SolutionRead Only
0 2 * * * /scripts/backup.sh > /var/log/backup.log 2>&1
Practice Sets
This question appears in the following practice sets: