On my Ubuntu system I had a lynis script set up to check my company computer’s setup daily and upload a report. The script ran fine when I ran it directly at the command line, but it never seemed to run via cron.
I examined the error output that cron emails you and found this…
run-parts: failed to exec /etc/cron.daily/lynis: Exec format error
run-parts: /etc/cron.daily/lynis exited with return code 1
Looking up Exec format error, I found this post suggesting to make sure to have a shebang at the beginning of your cron script.
I added the following line to my script:
…and now the script works just fine. Thanks, jofisch!