1

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

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

2 Answers 2

2

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.

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .