37

I want to edit my crontab file to schedule a script. Where do I find it?

4 Answers 4

21

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.

4
  • 3
    And if you want to see your crontab content use crontab -l
    – Ermiar
    Sep 4, 2010 at 13:06
  • 1
    I would highly recommend CronniX. It provides a much (much!) easier way of setting up cronjobs.
    – daviesgeek
    Nov 10, 2011 at 7:52
  • answering a different question
    – Lloyd
    Apr 2, 2022 at 21:24
  • @Lloyd I would note the OP thinks that this HAS answered the question so they have explicitly said that this DOES answer the question
    – mmmmmm
    Apr 3, 2022 at 9:34
39

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

5
  • In Snow Leopard, the user crontabs are stored in /var/cron/tabs, as well. Nov 22, 2014 at 16:22
  • 5
    On my mac (v10.11, el capitan) I found it in /private/var/at/tabs/. I used find / -iname *cron*.
    – AlexMA
    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.
    – Dickster
    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.
    – GDP2
    Dec 30, 2021 at 20:42
  • All these files are headlined with # DO NOT EDIT THIS FILE - edit the master and reinstall
    – geotheory
    May 3, 2022 at 13:54
6

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
0
5

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.

4
  • answering a different question
    – Lloyd
    Apr 2, 2022 at 21:23
  • 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
    – mmmmmm
    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.
    – Lloyd
    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.
    – mmmmmm
    Apr 3, 2022 at 10:42

You must log in to answer this question.

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