Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 moved my system from ubuntu 9 to debian 5 and the cron each time that try to execute a script throws...

-bash: ./ /bin/sh^M: bad interpreter: No such file or directory

all my scripts begin with


any clue ? should I change the shell cron is running ? it is using another shell ?

share|improve this question
up vote 4 down vote accepted

That ^M bit makes me think that your script uses CR-LF line endings. This usually happens when you edit a file using a Windows text editor.

To fix it, install the tofrodos package and convert the file:

sudo aptitude install tofrodos
fromdos -b /path/to/
share|improve this answer
great, I'm using this, it worked perfectly. I used a windows machine as backup before the migration, that is why. Thanks – Rodrigo Asensio Jun 30 '10 at 11:57

You have carriage returns in your document (Probably edited with a Windows program). You need to run:

cat | tr -d '\r' >

Make sure that you use a new file name like I did in my example ( You can read this blog post for the full story.

share|improve this answer
Here, have a UUOC award. :-p – ThatGraemeGuy Jun 30 '10 at 11:51
Well since tr doesn't take filename arguments I figure that is a little clearer than tr -d '\r' < input > output – Kyle Brandt Jun 30 '10 at 12:19

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.