crontab command not run

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


Solution 1:

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.

Solution 2:

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.