0

I have a script in /etc/cron.hourly that I want to run. The script is something like this:

#!/bin/sh -e

echo "Doing something"
eval $(do_something)
exec >> /tmp/log 2>&1

and

$ ls /etc/cron.hourly
drwxr-xr-x  2 root root 4096 Aug  1 11:31 ./
drwxr-xr-x 94 root root 4096 Aug  1 11:37 ../
-rw-r--r--  1 root root  102 Nov 16  2017 .placeholder
-rwxr-xr-x  1 root root  131 Aug  1 11:31 workSomeThing*

and

$ sudo run-parts --report /etc/cron.hourly

Shows that it runs correctly.

But the script doesn't run by it self every hour...

Edit:

# cat /etc/crontab
17 *    * * *   root cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

and

# sudo systemctl status cron.service 
● cron.service - Regular background program processing daemon
   Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-07-25 11:03:27 UTC; 1 weeks 0 days ago
     Docs: man:cron(8)
 Main PID: 719 (cron)
    Tasks: 1 (limit: 1152)
   CGroup: /system.slice/cron.service
           └─719 /usr/sbin/cron -f
  • Do you have the entry for cron.hourlyin your /etc/crontab? – Gerald Schneider Aug 1 '18 at 12:20
  • I guessed that it came pre configured for this... but I think it has them: ( from /etc/crontab) 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) – TazGR Aug 1 '18 at 12:37
  • Please don't add information as comments, edit your question instead. This is unreadable here. But it seems like it is there, yes. Is your crond running? – Gerald Schneider Aug 1 '18 at 12:54
  • I assume you mean cron.service in systemd, yes it is. – TazGR Aug 1 '18 at 12:59
  • Well, if no error shows up in the system logs I'm out of ideas. – Gerald Schneider Aug 1 '18 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.