Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a CentOS 6 machine I am trying to run some cronjobs on and the jobs are failing complaining about a carriage return (^M) on the end of the line. Example /var/log/cron entry:

CROND[20344]: (root) CMD (/usr/local/bin/php /usr/local/bin/somescript.php >/dev/null 2>&1^M)
CROND[20213]: (root) CMD (/usr/local/bin/php /usr/local/bin/somescript.php^M)

All this works fine on CentOS 5.x, so looks like it's a CentOS 6 thing. Any suggestions?

share|improve this question
maybe the master control program can help? he was always fond of end-of-lines ? – SpacemanSpiff Sep 8 '11 at 14:05

Use an editor that uses the correct line organisation. A quick fix is

export EDITOR=vi
crontab -e

where ^V^M is Crtl+vCrtl+m

share|improve this answer

How are you editing the crontab file? Was it copied using any Windows systems, notepad, etc?

These are not UNIX linebreaks. The ^M is a hard carriage return (sometimes known as \r when using escape sequences.) Windows line endings are \r\n (Carriage return, Line Feed) while UNIX line endings are simply \n.

If you used ASCII-mode FTP, or a Windows text editor at any point to get the file contents on the new CentOS system, that's likely the issue.

share|improve this answer

Install dos2unix and convert it to Unix line ending:

# dos2unix /var/spool/cron/root
share|improve this answer
Don't forget cron's law: You shall not edit the cron file by hand. See Iain's answer how to do it the right way. – mailq Sep 8 '11 at 14:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.