Howto set-up a crontab file

Howto set-up a crontab file

What is a crontab?

In Linux, Cron is a daemon/service that executes shell commands periodically on a given schedule. Cron is driven by a crontab, a configuration file that holds details of what commands are to be run along with a timetable of when to run them.

Creating a crontab file

You can create a crontab file by entering the following terminal command:

crontab -e

Entering the above command will open a terminal editor with a new blank file, or it will open an existing crontab if you already have one. You can now enter the commands to be executed, see syntax below, before saving the file and exiting the editor. As long as your entries were entered correctly your commands should now be executed at the times/dates you specified. You can see a list of active entries by entering the following terminal command:

crontab -l


A crontab file has six fields for specifying minute, hour, day of month, month, day of week and the command to be run at that interval. See below:


Writing a crontab file can be a somewhat confusing for first time users, therefore I have listed below some crontab examples:

* * * * * <command> #Runs every minute
30 * * * * <command> #Runs at 30 minutes past the hour
45 6 * * * <command> #Runs at 6:45 am every day
45 18 * * * <command> #Runs at 6:45 pm every day
00 1 * * 0 <command> #Runs at 1:00 am every Sunday
00 1 * * 7 <command> #Runs at 1:00 am every Sunday
00 1 * * Sun <command> #Runs at 1:00 am every Sunday
30 8 1 * * <command> #Runs at 8:30 am on the first day of every month
00 0-23/2 02 07 * <command> #Runs every other hour on the 2nd of July

As well as the above there are also special strings that can be used:

@reboot <command> #Runs at boot
@yearly <command> #Runs once a year [0 0 1 1 *]
@annually <command> #Runs once a year [0 0 1 1 *]
@monthly <command> #Runs once a month [0 0 1 * *]
@weekly <command> #Runs once a week [0 0 * * 0]
@daily <command> #Runs once a day [0 0 * * *]
@midnight <command> #Runs once a day [0 0 * * *]
@hourly <command> #Runs once an hour [0 * * * *]

Multiple commands

A double-ampersand “&&” can be used to run multiple commands consecutively. The following example would runcommand_01 and then command_02 once a day:

@daily <command_01> && <command_02>

Disabling email notifications

By default a cron job will send an email to the user account executing the cronjob. If this is not needed put the following command at the end of the cron job line:

>/dev/null 2>&1

Specifying a crontab file to use

As mentioned at the top of this post, you can create a new crontab file with the “crontab -e” command. However, you may already have a crontab file, if you do you can set it to be used with the following command:

crontab -u <username> <crontab file>

Therefore the following command…

crontab -u tux ~/crontab

…would set Tux’s crontab file to that of the file named “crontab” residing in Tux’s home directory.

Removing a crontab file

To remove your crontab file simply enter the following terminal command:

crontab -r

Further information

Refer to the man page for further information about crontab. Enter the terminal command:

man crontab

External links

Some external links for your browsing pleasure:


How to mount NFS shares in OSX Mountain Lion

How to mount NFS shares in OSX Mountain Lion

Problem: Mars and Venus and NFS 

You have two (or more) machines and you want to mount a drives with NFS from one machine to the other machine.   For our purposes, the first machine (sharing) is Mars and the second (mounting the share) is Venus.  So, you want to share an NFS mount from Mars with Venus.  Mars is running OSX Snow Leopard or later, and Venus is running Mountain Lion.   Mountain Lion no longer has the “Mount NFS Share” GUI utility in the Disk Utility.


Apple took it upon themselves to remove the NFS share utility from the disk utility for various reasons.   I believe that they removed it to protect their customers, because NFS is a network file sharing protocol that is insecure if it’s exposed directly on the internet.   It’s perfectly fine, however, to run NFS behind a firewall on your home desktop computers.   I wouldn’t have any NFS exports  on a laptop, since a laptop travels.    So, why use NFS?   Well, the advantage is that you don’t actually have to enable sharing in the System Preferences, you just need to modify one file.

As always, make sure that your Time Machine has a good backup.  And always make backup files of any existing system files before you change them.

How to share the NFS mount from Mars

I want to share a volume from Mars, so I need to edit the file “/etc/exports” file on the Mars machine.


Mars:~ jeffreyspencer$ sudo nano /etc/exports

Add a line in the exports file to mount the volume and/or directory that you want to export on the network.


/Volumes/Mason -mapall=jeffreyspencer:staff

Mason is the volume which is being shared via NFS from Mars. You can specify the entire volume, or a path to a specific directory.  I’m sharing the whole flipping thing – because that’s how I roll.   I am mapping all users to my user account since I’m on a trusted network and I’m the only user.   I am sharing the NFS mount with two machines, one located at +150 and the other at +165.  Save the file.

Now that the  exports file is saved, turn on the NFS daemon.


Mars:~ jeffreyspencer$ sudo nfsd start

How to mount Mars NFS shares on Venus

Working on Venus now, open a finder window, and then click on the top bar “go” menu, and then click “Connect to server.”



Screen Shot 2013-08-10 at 11.15.06 PMYou are going to mount an NFS drive from Mars, which has exported /Volumes/Mason location in the exports file.   After you enter the location, save the entry (press the plus sign) and then press “connect” to mount the NFS drive.  Now, browse to the current computer “Venus” in the finder and . . .


(American comfortable with their bastardized heritage, myself included, might use the phonetic “Wala”)
Your NFS drive is now mounted.

Screen Shot 2013-08-10 at 11.15.47 PM

Machines are stupid.   Your job, therefore, is to be smarter than a machine.

You can read about the AutoFS system contained in OSX and the different methods used to mount drives using Apple’s Technical White Paper on the subject.

OSX Boot0 Error on Large Hard Drives: The Unofficial Guide

OSX Boot0 Error on Large Hard Drives: The Unofficial Guide

The Boot0 Issue:

Upon successful installation, boot from hard drive results in a boot0 error:


Loading Operating System …
 boot0: GPT
 boot0: test
 boot0: test
 boot0: GPT
 boot0: test
 boot0: test
 boot0: error

The Actual Problem:
Due to the storage size of large drive, manufacturers had to change the default block size from 512 bytes to 4,096 bytes. The large drives are known as “Advanced Format” or 4K drives. Initially this was only seen on drives larger than 1 TB, but this change will be standardized and on all drives to lower manufacturing costs.  Windows and Linux resolved their boot loaders quickly, but OSX was a little slow to catch-up because Apple didn’t ship systems with drives larger than 1TB until a couple of years ago.  As part of this change there is an issue with OS X writing the boot code to the MBR sector.  Thankfully, you can write to the MBR manually (Yay!) in order for the OS to boot.  So, yes – you can purchase and replace that old Apple 1TB drive with a nice shiny 2TB drive.

Be mindful – your mileage may vary.   If you’re not a geek or a genius – you should just accept Apple’s configuration and/or buy a new machine.


1. Install Mountain Lion from a USB drive.  (if you don’t have one, google it)
2. Boot new installation using the same USB drive.
3. Run install scripts as normal – network, sound, etc.
4. Reboot system back into Mountain Lion installer from the USB.
5. At the second prompt (after welcome), run the Disk Utility and unmount the Mountain Lion drive you just installed.  The drive has to be “unmounted” and not in use when you write to the MBR.
6. Launch Terminal from the utilities menu and execute the following command:


dd if=/usr/standalone/i386/boot1h of=/dev/disk0s2

7. Exit Terminal
8. Reboot Normally
9. Laugh at the Sky

NOTE: The above instructions are based on OS X being installed to a hard drive connected to SATA port 0. If you are using a different port you will need to get the drive device name from Disk Utility by selecting the volume and clicking Info.  This post is intended as a personal note for my own use (had to do this on my box), but you may find it useful. You can find other guides on the internet that are similar if you don’t like this one.