Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am unable to configure a cron job to run by placing it in /etc/cron.hourly folder.

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

The file under cron.hourly is :

lrwxrwxrwx 1 root root   40 2010-07-26 14:52 check -> /usr/local/xxxx/check-interface.bash

Permissions on the file :

-rwxr-xr-x 1 root root 1.6K 2010-09-13 11:22 /usr/local/xxxx/check-interface.bash

There seems to be no errors reported in the var/log/cron logfile. No mention of the script is done. :(

share|improve this question
    
Are you sure crond is running? –  jamespo Mar 28 '11 at 15:33
    
yep, i restart the daemon after the changes manually. –  Ricko M Mar 28 '11 at 15:50
1  
chmod +x /usr/local/xxxx –  forcefsck Mar 28 '11 at 16:51
    
What version of Cron do you have (it's ok if you say what distribution you have)? Some versions have rules for naming files in /etc/cron.*. Is check the actual name of the symlink? Does the script run correctly if you run it manually? Are you sure it's not running and just having no visible effect? –  Gilles Mar 28 '11 at 18:48
    
Is this a debian system, per chance? –  Glen Solsberry Mar 29 '11 at 15:43
show 1 more comment

2 Answers 2

up vote 2 down vote accepted

In order to isolate the problem, move /usr/local/xxxx/check-interface.bash to /etc/cron.hourly/check , and then see if it runs.

If the script does run, then the problem is caused by an ownership/permissions or related issue which is preventing cron from executing scripts at /usr/local/xxxx/*.

If the script does not run, then the problem is most likely with your script itself.

As another sanity check, replace the contents of /usr/local/xxxx/check-interface.bash with something dead simple, like:

date > /tmp/check-interfaces.log 2>&1

And then see if /tmp/check-interfaces.log is actually being populated by your cronjob. If it does work, then the problem must be with your original script.

share|improve this answer
1  
On several distros, run-parts explicitly skips files that have a period in them as they may have been generated by a package update. Maybe that's what he's running up against. –  Shadur Mar 29 '11 at 11:02
    
Care to elaborate on that please ? I am not sure what you mean by having a period in it. Thanks! –  Ricko M Mar 31 '11 at 9:22
add comment

I just want to confirm that as Shadur has mentioned earlier, the issue lies in the fact that by default the "run-parts" application used by cron will run only commands that contain only ASCII letters, _, and -. From the official man page:

   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.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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