run-parts gives an exec format error

I got a problem the other day with a Linux script I made.
Basically, the script was working perfectly fine if I executed it directly from the command line but whenever I tried to run it with run-parts it failed!

This is the error message it returned:

%prompt> run-parts --report /etc/cron.daily
run-parts: failed to exec /etc/cron.daily/myscript: Exec format error
run-parts: /etc/cron.daily/myscript exited with return code 1

Actually, the answer of this problem is quite simple! 🙂
I simply forgot the shebang on the first line of the script…

So, if you get the same error than me, make sure you have the following line at the beginning of your script:


, , , , ,

  1. #1 by Eissa on 08 Nov 2012 - 08:39

    it is worked with me

  2. #2 by Lance on 04 Jun 2013 - 16:54

    Been trying to work out why my script wouldn’t execute for about a week now.
    Thank you!!!!

  3. #3 by BoB on 22 Mar 2014 - 07:05

    Thank you !!! I’ve been searching for hours ! 🙂

  4. #4 by ACL on 09 Nov 2015 - 18:10

    This worked for me. I had the shebang on the second line of the script and it was giving me the exec format error. Moved it to the first line and will see what happens tomorrow when run-parts tries to execute it (cron.daily).

  5. #5 by Noob on 25 Mar 2017 - 22:54

    Worked. My issue was there was a commented line describing the script before the shebang. Swapped the two around and it worked.

(will not be published)