I have a cron task with "printf":
#!/bin/bash
# ..........
printf "hello\n"
# ..........
It runs once in N hours. However, in /var/log/syslog
I don't see any logs with "hello" at all. Why not?
I have a cron task with "printf":
#!/bin/bash
# ..........
printf "hello\n"
# ..........
It runs once in N hours. However, in /var/log/syslog
I don't see any logs with "hello" at all. Why not?
The designers of cron assumed that cron users would appropriately direct output (stdout & stderr) and, thus, any output that was not redirected to either a file or to another process was likely a mistake.
Their election was to forward via sendmail all spurious (i.e., un-redirected) output to the owner of the cron job.
If you check /var/log/syslog, you should find an entry like:
Jun 26 22:18:01 sys0af3e3 CRON[16529]: (CRON) info (No MTA installed, discarding output)
The program typically called by cron is /usr/sbin/sendmail, but you can verify which is used in your implementation by running:
strings /usr/sbin/cron | grep -i '^/.*mail'
If you were to create /usr/sbin/sendmail (it should be executable) with the contents:
echo "####################" >> /tmp/mail.out 2>&1
date >> /tmp/mail.out 2>&1
cat >> /tmp/mail.out 2>&1
then run:
systemctl restart cron #this must be run as root
you would find your missing output appended to the file /tmp/mail.out after every run.
Don't forget to remove /usr/bin/sendmail and restart cron after you finish your test.