How to eject a drive automatically after pen drive is plugged in? I have set up a .plist file which would automatically backup my files whenever I plug in my pen drive but I would like to eject it after the process is complete. How do I accomplish this?

Here is my job definition - how do I modify it to eject my drive after backup is complete:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd &gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.company.popup&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;sh&lt;/string&gt;
        &lt;string&gt;-c&lt;/string&gt;
        &lt;string&gt;/usr/local/bin/backup&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;StartOnMount&lt;/key&gt;
    &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


PS. I have put thus file under ~/Library/LaunchAgents
You just have change the UNIX executable file.Modify it like  rsync -aH source destination &amp;&amp; diskutil eject /Volumes/BACKUP &gt;&gt; desktop/log.txt