Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8044

Beginners • Re: log file for cron

$
0
0
FWIW Not sure what you are looking for but I create a LOG file for each running of my CRON jobs. From CRONTAB -l
# m h dom mon dow command
0 21 * * * /home/pi/pi_lib_backup.sh > pi_lib_backup_cron.log
0 22 * * * /home/pi/bkp_to_ehost.sh > bkp_to_ehost_cron.log

That won't capture any error messages. For those you need to append 2>&1 to each command as well.

I do it that way too.* I've not checked under Boolworm but under Bullseye and earlier even with EXTRA_OPTS="-L 1" all you get in syslog and/or the systemd journal is messages from the cron daemon not from the called process.

Your other option is to install an MTA** and let the cron daemon email you the command output.

[shameless self promotion]
Cron – A Beginner's Guide
[/shameless self promotion]

*: with capture of stderr (2>&1)
**: Mail Transfer Agent

Statistics: Posted by thagrol — Mon May 06, 2024 11:52 pm



Viewing all articles
Browse latest Browse all 8044

Trending Articles