Cron.hourly won't run

Ok, So I’ve made my script, I dropped it in /etc/cron.hourly then I chmod 777 the file but it won’t run (automatically). If I manually run it, it works fine. Do I need to do anything else?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Entries in cron.hourly are run by the run-parts mechanism (man run-parts for more info). And run-parts is choosy about what filenames it considers valid.

For example, giving your script an extension will make it invalid and result in the job not being run. [a-zA-Z0-9_-] are the valid characters, so the ‘.’ makes it invalid.

When adding a job to /etc/cron.hourly ( or .daily, .weekly, etc), always test afterwards that run-parts will actually run it by issuing the command:

run-parts --test /etc/cron.hourly

If by running this command it shows your file it means it worked. Otherwise, if doesn’t show anything your file name is not valid.

What was the name of your script?

Solution 2

Why not using crontab ( /etc/crontab ) and use */1 in the hour field. I have used this to run a script every 5 min and it works well:

# m h dom mon dow user  command
* */1  * * *   user    command

Solution 3

DaithiF’s answer should be the right answer.

Also, my script didn’t have #!/bin/bash in the first line. Even though the script could be executed with the command line, run-parts rejected it saying “Exec format error”.

Changing the file name from to scriptname and adding the #!/bin/bash into first line enabled my script to run hourly.

Solution 4

Your problem is probably down to the overly open permissions, which allows anybody to edit your file. Try 755 instead.

Looking in the cron entries in your syslog output should confirm this.

Solution 5

When you run

crontab -l

is this task on the list?

if not, add it

crontab -e

add this line

0 * * * * yourScript

if it is in this list, try to add the path of programing language to the top of your script


bash: #!/bin/bash

This 2 things always solved my problems 🙂

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply