Search code examples
cron

Why does my cron output file name have a \r at the end?


In my cron spool I am doing:

5 * * * * php test.php >> test.txt

I can see that the cron is running the PHP script but the output file is called:

"test.txt\r"

why?

how can I open that file to see what's inside or how can I make cron not append that \r?


Solution

  • I believe you must have edited your crontab on a Windows machine.

    Linux terminates its lines with \n. Windows does so with \r\n. On Linux, \r is just another character. Thus, your crontab probably reads:

    5 * * * * php test.php >> test.txt\r
    

    and will show you that if you open it with an editor on Linux that shows control characters.