37

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

daviesgeek
  • 38,901
  • 52
  • 159
  • 203
Casebash
  • 4,393

4 Answers4

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

spkane
  • 739
  • In Snow Leopard, the user crontabs are stored in /var/cron/tabs, as well. – Jack Humphries Nov 22 '14 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 '16 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 09 '19 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 '21 at 20:42
  • All these files are headlined with # DO NOT EDIT THIS FILE - edit the master and reinstall – geotheory May 03 '22 at 13:54
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.

Studer
  • 8,779
  • 5
  • 38
  • 38
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
nohillside
  • 100,768
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.

oa-
  • 7,716
mmmmmm
  • 30,160
  • answering a different question – Lloyd Apr 02 '22 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 03 '22 at 09: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 03 '22 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 03 '22 at 10:42