1

I've noticed that hourly and daily crons are not running, I moved them to crontab, and everything is fine:

#!/bin/bash

now=$(date)
echo 'It is '$now

The command line:

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

returned blank

EDIT:

# ls -lsAF
total 8
4 -rw-r--r-- 1 root root 102 Apr  2  2012 .placeholder
4 -rwxr-xr-x 1 root root 254 Mar 18 06:52 testEcho*

Before the name was "testEcho**.sh**", I renamed it to "testEcho"

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

Now the value was returned, I will test it and get back to you

Thanks in advance

3
  • Welcome to AU ! Please list the full content of yr /etc/cron.hourly using the ls -lsAF /etc/cron.hourly cmd and add it to yr post by editing it. Notify me of yr edit using @Cbhihe in a subsequent comment below. – Cbhihe Mar 19 '16 at 8:46
  • @Cbhihe : code edited above – Abu Rayane Mar 21 '16 at 3:11
  • @heemayl beat me to the answer. I was precisely thinking about non standard spelling of file names in relation to the --lsbsysinit and --regex options. You will find looking at man run-parts very useful in that context. Heemayl nailed it while I was asleep ! – Cbhihe Mar 21 '16 at 8:46
1

The hourly and daily (and also weekly, monthly)cron jobs are run by run-parts command. My /etc/crontab has:

17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

The thing to note is that run-parts is very sensitive to file names. From man run-parts:

If neither the --lsbsysinit option nor the --regex option is given then the names must consist entirely of ASCII upper- and lower-case letters, ASCII digits, ASCII underscores, and ASCII minus-hyphens.

So as the file is named testEcho**.sh**, it fails the name checking of run-parts and hence run-parts ignores it.

You need to rename the file(s) to conform to the run-parts naming policy or you can execute the files directly by adding relevant entry in crontab.

3
  • This is exactly it ! Kudos +1 ;-) – Cbhihe Mar 21 '16 at 8:46
  • @Cbhihe stolen your answer ;) – heemayl Mar 21 '16 at 8:51
  • 1
    No, I wouldn't say stolen. You were faster and your time zone was more favorable. I guess I'll have to quit sleeping from now on. Congrats ;-P – Cbhihe Mar 21 '16 at 9:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.