Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to get execute a cron job everyday at noon but i can't get it to run. To test it i even tried something like a simple create command but it never runs, it seems as if the file isn't even used. I also can't see anything going wrong in the log.

0 12 * * * mkdir /path/to/folder

So is there something wrong with this line or should i look elsewhere?

I created the crontab as root with crontab -e

share|improve this question
    
cron can only evoke the process if permissions are correct. did you set the permissions correctly –  Ringtail Mar 6 '12 at 11:08
    
i didn't change any permissions, what should they be? –  dazz Mar 6 '12 at 11:16

2 Answers 2

up vote 2 down vote accepted

cron does not know where to find mkdir. So if you do not include a PATH in your cron then always use absolute paths. This works:

0 12 * * * /bin/mkdir /path/to/folder

Have a look at the part starting with using cron in the link. You can put a path and other variables at the top of cron like so:

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

That way you have access to /sbin/, /bin/, /usr/sbin/ and /usr/bin/.

I myself prefer to only include a script in cron and set the commands inside that script.

share|improve this answer

Maybe a dumb question, but have you tried a

sudo service cron restart

after editing? In my case, cron only get changes if I restart it.

share|improve this answer

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.