I want to edit my crontab file to schedule a script. Where do I find it?
4 Answers
If you don't want to use launchd
, you can edit your crontab as you would do on any unix systems :
crontab -e
Or, you can use a GUI software like CronniX.
-
3
-
1I would highly recommend CronniX. It provides a much (much!) easier way of setting up cronjobs. Commented Nov 10, 2011 at 7:52
-
-
@Lloyd I would note the OP thinks that this HAS answered the question so they have explicitly said that this DOES answer the question– mmmmmmCommented Apr 3, 2022 at 9:34
In Mac OS X Lion the user crontabs
are stored in /var/at/tabs
. In the past they were located in /var/cron/tabs
.
You should use crontab -e
to interact with these in general, but knowing the location is useful for when you want to restore them from a backup of your disk, or something similar.
Updated 2022-01:
/var
is a link to/private/var/
./usr/lib/cron
is a link to/var/at
.
The real primary directory is /private/var/at
with the crontab files being stored in /private/var/at/tabs
-
In Snow Leopard, the user crontabs are stored in /var/cron/tabs, as well. Commented Nov 22, 2014 at 16:22
-
5On my mac (v10.11, el capitan) I found it in
/private/var/at/tabs/
. I usedfind / -iname *cron*
.– AlexMACommented Aug 26, 2016 at 15:04 -
AlexMA is correct, and on 10.12 (and above) you may need to become 'root' to have permission to access these tables, which have usernames. I use 'sudo bash' to become 'root', and 'exit' when I'm done.– DicksterCommented Oct 9, 2019 at 18:15
-
Apparently on newer versions, crontabs are stored under:
/usr/lib/cron/tabs
. Although, you need root permission to view the contents of that folder.– GDP2Commented Dec 30, 2021 at 20:42 -
All these files are headlined with
# DO NOT EDIT THIS FILE - edit the master and reinstall
Commented May 3, 2022 at 13:54
It should be noted that if you aren't accustomed to using vim (the default crontab editor) then you can specify your editor as follows:
VISUAL=nano crontab -e
The OS X way is to use launchctl to run jobs at a time.
For ease of use there are GUIs called Launch Control and Lingon.
-
-
1@Lloyd - The question is how to schedule a script . crontab is just how you do that on many Unixes but on macOS you use launchctl– mmmmmmCommented Apr 3, 2022 at 9:32
-
read your answer again and ask whether it answers "Where is my crontab file?".. that's the original question and my question too.– LloydCommented Apr 3, 2022 at 10:38
-
The answer is you don't do that on macOS you use another method. The end result is scheduling a script and that is what matter Using crontab is using the wrong tool so it is better to suggest the better way. I read the question as "I want to .... to schedule a script." Look at the required end result not the method to do it which happens to be not the best for macOS.– mmmmmmCommented Apr 3, 2022 at 10:42