Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save t18n/13267979ba9259d50df91654ebc83a8a to your computer and use it in GitHub Desktop.
Save t18n/13267979ba9259d50df91654ebc83a8a to your computer and use it in GitHub Desktop.
Automatically run script on OS X with Crontab
  1. Prepare a bash script to run what ever you like to, in this case, I want to run my Mackup backup to backup all of my settings
 1   │ #!/bin/bash
 2   │
 3   │ cd /Users/turbo/Code/Mackup
 4   │ mackup backup -f
 5   │ git add .
 6   │ git commit -m "Updated changes"
 7   │ git push
  1. Add cronjob for MAC using Crontab Run env EDITOR=vim crontab -e command to open Crontab config file with vim A cron job format is:
- - - - - USER command
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)

For example:

1   │ 0 12 * * *  cd && ./mackup.sh

Add a cron job and save the file.

  1. Run crontab -l to check if task is added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment