Friday, April 19, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 4992  / 3 Years ago, mon, june 28, 2021, 2:32:06

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


More From » cron

 Answers
4

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.


[#40006] Tuesday, June 29, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ormlai

Total Points: 292
Total Questions: 106
Total Answers: 115

Location: Cape Verde
Member since Fri, Sep 16, 2022
2 Years ago
ormlai questions
Wed, Sep 28, 22, 00:17, 2 Years ago
Sun, Aug 7, 22, 22:05, 2 Years ago
Wed, Jun 16, 21, 03:50, 3 Years ago
Sun, Feb 6, 22, 09:11, 2 Years ago
Mon, Jul 12, 21, 10:00, 3 Years ago
;