Computers were invented with the intention of automating tedious tasks. The reality today however, is that along with computers have come a lot other tedious tasks to add to the originals. But thankfully *nix variants have a handy tool called cron. cron is a terminal command that allows you to designate a set of commands and use them at set time intervals. So here’s a rundown on a personal implementation of cron that updates a few things that are on version control:
If you’ve read some of my previous posts you’ll know I a big proponent of MacVim. One reason is because it’s
open source and a lot of people update it frequently. And since I like to stay as up to date as possible I
created a crontab file (the file that stores your commands, and sets the time intervals that cron uses) that automatically updates it, and updates my TextMate bundles for me.
Here’s what mine looks like:
1 22 * * * cd /Applications/vim7/; git pull; cd src/; ./configure --enable-gui=macvim --with-features=huge --enable-perlinterp --enable-cscope --enable-rubyinterp --enable-pythoninterp --enable-multibyte --with-compiledby=Travis; make; cd MacVim; xcodebuild; rm -rf /Applications/MacVim.app/; cp -R /Applications/vim7/src/MacVim/build/Release/MacVim.app /Applications/;
1 22 * * * mateup;
The numbers and stars at the beginning of the lines signify to cron the time intervals. The numbers/fields go in this order:
- Minute (0-59)
- Hour (0-23)
- Day of the month (1-31)
- Month (1-12, or a name like jan, feb, and so forth)
- Day of the week (0-6, where 0 is Sunday, or a name like mon, tue and so forth)
- Command
Now every night at 10:00PM it will automatically do every command that you see above. cron will automatically know what to do, however to make your own crontab file you need to do the command: crontab -e, which if you don’t have a crontab file will open up your text editor for you to make a new one and if you do have one it will open it up to edit it.
Note for the mateup command, it’s actually a script that you can get here and it updates all the TextMate bundles.