Why my cron job wouldn’t run

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!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.