The cron daemon is run by 'root' user in its own shell. By default, cron will append a system mail sent to the user running the script (that's why you see the sender as 'root' in the system mail). The 'user' is the user you were logged in as when setting the crontab. The mail will contain console and error messages. On Ubuntu, the mail file is viewable at /var/mail/<username>
.
If no $TERM
variable is set, cron will emit a tput: No value for $TERM and no -T specified
error in the mail file. To stop these errors, set the $TERM
variable using TERM=dumb
(or another available terminal in your system, like xterm
) in the crontab. The toe
command will show you the terminfo definitions on the current system. If you lack that command, you can see the raw data in /usr/share/terminfo
on most Linux systems.
Even though you have stopped the errors, you may still get appended system mail with console messages. This file will fill up like a log over time, so you may want to stop these messages. To stop cron system mail, set the MAILTO
variable using MAILTO=""
So your crontab might look like:
MAILTO=""
TERM=xterm
* * * * * sh /path/to/myscript.sh
You can view the crontab (for the user you are signed in as) with 'crontab -l'.