Why does my cron job create a log with a trailing question mark?
I have the following cron job:
*/5 8-20 * * * php /var/www/user/cron_email.php >> /var/www/log/log.txt
It creates the following file:
david@ubuntu:/var/www/log$ ls -l
-rw-r--r-- 1 root root 540 2011-05-30 17:10 log.txt?
Why is it creating a trailing question mark? How can I stop that?
(I am logging in on the console and seeing the results with no editor so I know that "?" is there.)
And this is the only file that has a trailing '?' so I know its not an editor problem. I am not even using any editor, Im just viewing the console CRT screen.
Solution 1:
Running this command will provide more info:
$ crontab -l | cat -tve
I'm fairly confident you will see extra characters at the end of the output, something like this:
*/5 8-20 * * * php /var/www/user/cron_email.php >> /var/www/log/log.txtM-U$
the dollar sign just signals end of line (-e option to cat). Anything betwee .txt
and $
is extra garbage, probably due to reasons listed in other answers.
The easiest way to fix this is to set your $EDITOR
to a simple editor and re-edit the crontab. For example:
$ EDITOR=/usr/bin/pico crontab -e
then remove any extraneous characters at the end of the line.