A job runs without a terminal. Whatever it prints, you will not see on screen.
cron runs the command through /bin/sh as the table's owner, in their home directory. cron records every run in the journal: sudo journalctl -u cron shows a line CRON[…]: (student) CMD (command).
cron mails the job's output — errors included — to the table's owner. The training machine has no mail service, so after the run the journal gets (CRON) info (No MTA installed, discarding output): the output was thrown away. That is why a job that silently fails is checked through the cron journal, and its command by typing it in the terminal.
cron reads one character its own way: it turns % in a command into a newline and feeds everything after the first % to the command as input. To get a % through to the command, write it as \%.
After a job run the cron journal holds these lines. What does the second one mean?
CRON[1227]: (student) CMD (/usr/local/bin/report.sh)
CRON[1226]: (CRON) info (No MTA installed, discarding output)
-
The run happened, as the
CMDline shows.No MTA installedis about the job's output: there is nowhere to mail it. -
cron writes this line when the job produced output. A job with no output leaves no such line, and an error counts as output.
cron mails the job's output, but the machine has no mail service, so it throws the output away. What the command prints shows up when you type it in the terminal.
Key points
-
A job runs through
/bin/shas the table's owner; every run shows insudo journalctl -u cron. -
cron throws away a job's output and errors:
No MTA installed, discarding output. -
%in a cron command means a newline; pass it to the command as\%.