Crontab Not Working in MacOS Sierra

Having used Linux and Unix since 1995, I find myself pretty much locked at the hip with crontab to keep my jobs working on a given schedule.  Go figure, as soon as I update my MacOS machine to Sierra and at the same time want to get Clam antivirus configured to auto-scan, I find out it’s not working in there.  It was a bit of a rabbit hole situation, where one thing lead to another.  In the end, I found out that cron has been deprecated in OS X/MacOS, and now Launchd is default and supported.  One of those things that rubs me the wrong way, but it is what it is since it’s not designed to be a server or a Unix system really.

I found /usr/lib/cron to be symlinked to /var/at, and /var/at has a cron.allow file (/var/at/cron.allow).  ‘At’ is also disabled by default.  ‘Atrun’ controls it.  I vi’ed /System/Library/LaunchDaemon/ and found out that cron was deprecated.

Here’s the skinny on Launchd.  plist files handle the applications that will run within it.  It’s an XML based file which tags a string name for it, the program application that will run, arguments, when it will run, and how frquently.  A description and logs are designated in there as well.  Once one is seen, it’s relatively simple to edit and create your own for any script or application you’d like to run.  That’s what I did.

/Library/LaunchDaemons – holds plist files for global services running as root
/Library/LaunchAgents – Holds plist files only used while users are logged on. (Run as ‘root’)
$HOME/Library/LaunchAgents – Hold plist files used when users are logged on. (run as the userid)

And on to the commands to control launchd… which kinda reminds me of systemd on newer Linux systems, disturbingly.
  • launchctl list – view currently registered plists
  • launchctl load -w <plist file> – adds and registers plist file, starting it.
  • launchctl unload -w <plist file> – remove and deregister plist file.

So, I wanted to have freshclam (clam antivirus script that updates clamav) run regularly.  I created this plist file (/Library/LaunchDaemons/net.clamav.freshclam.plist):

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “”&gt;
<plist version=”1.0″>
<string>Checks for and downloads updates to the ClamAV virus database.</string>



And a script I wrote that uses clam antivirus to scan my directories is run by this plist (/Library/LaunchDaemons/net.clamav.clamscan.plist):

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” “”&gt;
<plist version=”1.0″>
<string>Runs a clamscan on the /Users subdirectories</string>



After all is said and done, Launchd runs clam antivirus to scan my /Users subdirectories on a regular basis just in case I have something on here I shouldn’t.

It’d be nicer if there would just be an integrated scheduler with the Apple clam antivirus that would translate the scheduling into something that wouldn’t require learning how to build a Launchd script from the beginning.  I can see why they didn’t since it started on Linux and it’s easier to just toss something like this into crontab:

*/60 * * * * freshclam 2>&1 > /tmp/freshclam.log


MacOS / OS X – App that makes an app for your scripts

If you’re anything like I am, you have scripts that call do random things, or call other apps behind the scenes to set environments to do other things, etc etc.  The issue I run into is it doesn’t seem pretty to have aliases in my Applications folder.  You can’t set Icons for aliases, and it just sits there as a plain white Icon.  Not cool, man, not cool.  As I was studying Swift code tonight I ran across a gem I thought I’d share which helps amazingly with this problem!  It’s called Platypus, and it creates an app that will run scripts (bash, csh, tcsh, ksh, zsh, Perl, Python, Ruby, Applescript, Tcl, Expect, PHP, Swift, and others) that you set the name for and environment.  Details below.


It’s fairly straight forward, which is nice.  The app name is free form, and so is the author name.  The script path you can type in yourself or find it with ‘select script…’.  If you’re adventurous, the “new” button can be used to create your script right there.
For me, the great part is the interface dropdown which allows you to pick how the called script will be interfaced with.  I pick ‘none’ so it runs in the background out of view.  I have a few ‘wine’ scripts that I call with this, and allows it to run out of sight and out of mind.  As far as icons, I’ve used jpg and ico files by selecting the gear under the picture and choosing ‘select image file…’.  The ones that are able to be used are not shaded out, which is great.

When you click ‘create app’, it will ask you where you want to save it along with the name of the app.  There are other development related selections underneath that can be chosen which I don’t have any experience with.
Screen Shot 2017-07-19 at 9.22.17 PM

I’ve so far used this to call ‘Microsoft Money 2002’ via Wine, along with calling ‘Notepad++’ via Wine.  It works nicely, for me.  It’s available for free (you can donate if you enjoy it) at

The dude made an awesome app.

For those interested, he also makes another app called “Sloth” that acts as a visual version of the cli tool ‘lsof’.  Kinda neat, I just started looking at it about 10 minutes ago.  It’s available off of his main page, just remove “platypus” from the URL and you’ll see links. (or just go to
Kinda neat to immediately see where Google Drive is connecting to, that easily.

Macbook Pro external display only while on battery

I haven’t really done this until now, but I figured I’d share how I worked around my issues.

Since I use my new 2017 Macbook Pro as a desktop & laptop, I don’t want to constantly charge the battery while I have it docked.  The problem is that by default MacOS sleeps when the laptop lid is closed.  This is a problem when you don’t want it open & just want to use an external monitor connected via HDMI (through an HDMI -> USB-C adapter) or USB-C directly.  After searching around for a bit, I found a free utility app that helps with this, named “InsomniaX“.  It doesn’t come in a dmg file, just a heads-up.  It’s packaged in a tar.gz tarball which can be decompressed using archive utility.  That’ll drop it into the same directory as the tarball, and you’ll drop and drop it to your Applications folder.

It’s very spartan and almost invisible unless you’re looking for it.  It sits in the tool bar on top, and looks like a crescent moon.  The drop-down menu appears like this when clicked:
Screen Shot 2017-07-15 at 2.31.29 PM

That pretty much sums it up.  As you can see, I selected “Disable Lid Sleep”, and I am operating primarily on my external monitor as I would when plugged in.  The difference when using the power adapter is there is a selection in the Energy Saver section of System Preferences that reads, “Prevent computer from sleeping automatically when the display is off”.  If desired, InsomniaX also has selections in the Preferences area to disable lid sleep while on AC along with starting the application on login.

Screen Shot 2017-07-15 at 2.43.04 PM

Anyway, it’s a neat little utility and does what it’s supposed to do.  Always nice to share those things when you run across them.  Have a great one!

Bootable OS X El Capitan on USB Stick

With the new version of OS X coming out shortly (El Capitan), here’s a way to make a bootable copy of it to your USB stick.  This process isn’t much different than previous versions, but I figured I’d post the instructions.  This wasn’t created by me, I just copied it from Lifehacker’s website because of the clean 1,2,3 layout already typed up.  Here it is.

The DIY Option: Terminal

  1. Download the El Capitan installer.
  2. Insert an 8GB (or larger) flash drive and give it a name. For this tutorial, we’ll use the name Untitled. Make sure the drive is formatted for OS X Extended (Journaled). If it isn’t, open up Disk Utility and format is so it is. Before you do so, back up any important data on that drive.
  3. Open up Terminal (Applications > Utilities).
  4. Type (or copy and paste) this command into Terminal, replacing Untitled with the name of your drive, then press Enter: sudo /Applications/Install\ OS\ X\ El\ --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ El\ --nointeraction
  5. Type in your password when prompted and press Enter.
  6. Let the command line to its work and don’t interrupt it until you see the final line that says Done. This can take up to a half hour, so be patient.

When it’s done, you can insert your USB drive into any Mac and the launch the installer by holding down the Option key when you boot up your computer.

EDIT June 27, 2016:
If you’ve run into issues with not being able to download El Capitan through the App Store, I ran into that issue today as well.  There are times when the App Store wants to be a complete pain in the butt.  Some people said to log out and try while logged out, and some say to try option-clicking the download button.  I found I had to take a two pronged approach.  I first had to remove all “Install El” directories in different locations, unmounting the flash drive with “Install El” on it, and rebooting.  All of that together fixed everything, oddly.  Thought I’d share.

OS X Yosemite In Bootable ISO format

Maybe you’re something like I am, and want to have a bootable ISO of OS X Yosemite to run under a VM on a Mac. (It’s not going to do very well on it’s own with PC architecture)
Nothing fancy, just an install that you don’t need to bend over backwards and pray to the deity of choice to make happen.  After looking around (since I’ve only really done it directly to USB flash and not to ISO really) I ran across this script made by someone else who wanted the same thing.  I don’t have the URL of where I got it, but I wanted to share.  Keep in mind, you will need to first download Yosemite through the Apple App Store, which will place it in the Applications folder.  Leave it there for the script to do it’s thing.

Just copy and paste this into a script and run it from the command line.  It will make an ISO called Yosemite.iso right on your desktop.  I have an SSD drive and it took approximately 2-3 minutes to complete.  I’m thinking on a regular harddrive with the amount of disk activity it will take longer, but well worth the wait.

Here it is (it’s all there, just not displaying properly.  When you select it all, it will copy fine):


# Mount the installer image
hdiutil attach /Applications/Install\ OS\ X\ -noverify -nobrowse -mountpoint /Volumes/install_app

# Convert the boot image to a sparse bundle
hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o /tmp/Yosemite

# Increase the sparse bundle capacity to accommodate the packages
hdiutil resize -size 8g /tmp/Yosemite.sparseimage

# Mount the sparse bundle for package addition
hdiutil attach /tmp/Yosemite.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build

# Remove Package link and replace with actual files
rm /Volumes/install_build/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/install_build/System/Installation/

# Copy Yosemite installer dependencies
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/install_build/BaseSystem.chunklist
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/install_build/BaseSystem.dmg

# Unmount the installer image
hdiutil detach /Volumes/install_app

# Unmount the sparse bundle
hdiutil detach /Volumes/install_build

# Resize the partition in the sparse bundle to remove any free space
hdiutil resize -size `hdiutil resize -limits /tmp/Yosemite.sparseimage | tail -n 1 | awk '{ print $1 }'`b /tmp/Yosemite.sparseimage

# Convert the sparse bundle to ISO/CD master
hdiutil convert /tmp/Yosemite.sparseimage -format UDTO -o /tmp/Yosemite

# Remove the sparse bundle
rm /tmp/Yosemite.sparseimage

# Rename the ISO and move it to the desktop
mv /tmp/Yosemite.cdr ~/Desktop/Yosemite.iso

Creating an application stack for a script

I’m sure there are others like myself who just want to run a script from the Applications folder. Nothing special, just a Unix script that runs a ‘wine’ command, or just about anything really. Unfortunately it’s not terribly pretty to simply rename it to xyz.command. I ran across a script that creates a stub body of OSX application stack for the script. It’s called applify. Basically all you have to do is:

applify scriptname “name you want to give it”

It will create a directory called name you want to give and you can drag-n-drop it wherever and run it from there with a click. I use it for wine applications right now, and probably unix scripts in the future.

I found the script at:

I pasted the following into a script in /usr/local/bin which is in my path, and it’s ready to go:


if [ “$1” = “-h” -o “$1” = “–help” -o -z “$1” ]; then cat <<EOF
appify v3.0.1 for Mac OS X –
Creates the simplest possible Mac app from a shell script.

Appify takes a shell script as its first argument:

`basename “$0″`

Note that you cannot rename appified apps. If you want to give your app
a custom name, use the second argument:

`basename “$0″` “My App”

Copyright (c) Thomas Aylott
Modified by Mathias Bynens
exit; fi

APPNAME=${2:-$(basename “$1” “.sh”)}

if [ -a “$” ]; then
echo “$PWD/$ already exists :(”
exit 1

mkdir -p “$DIR”
cp “$1” “$DIR/$APPNAME”
chmod +x “$DIR/$APPNAME”

echo “$PWD/$”


EDIT 01/18/2015:

To give an example of the script I’m using with Wine to run an application, my Microsoft Money script is as follows:

/Applications/ ‘/Users/situationalawareness/.wine/drive_c/Program Files/Microsoft Money/System/msmoney.exe’

I ran:
applify “MS money”

and it created an “application” in that folder that can be drag-and-dropped anywhere in Finder.  (i.e. into Applications)

Another note is how to edit the icon for the “Application” created.  First, create/find an icon around 512×512 in resolution.  Then, open it in your favorite editor, select all and copy to the buffer. (command-c)  Then, right click on the “Application”, and select “get info”.  Single-click on the icon picture in the upper left-hand corner of what popped up, then paste your buffer into there. (command-v)  The icon should appear in place.  It won’t be visible in the Applications folder until you’ve logged out and logged back in, however.

Creating a Boot Installer DVD for Apple OS X Yosemite

As most in the Apple world may have noticed, it’s not straightforward to create a boot CD to perform a clean install of the new OS X version, Yosemite. Sure, it’s easy to upgrade but that means you’re reliant upon a previous version of OS X which makes things a little precarious.

After downloading the install through the App Store, it will be in your Applications folder. Before doing anything else, you can do the following to create an ISO on your desktop that can be burnt to a DVD for future use.
NOTE: DVD installation of Yosemite is excruciatingly long. It can take 30-45 minutes to boot off of a DVD, due to the random file access. It’s best to use a USB flash, but at any rate the ISO is a good start.

Instructions for use in the Terminal (Every line has it’s own *, and has no return in it):

* hdiutil attach /Applications/Install\ OS\ X\ -noverify -nobrowse -mountpoint /Volumes/install_app

* hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o /tmp/Yosemite

* hdiutil resize -size 8g /tmp/Yosemite.sparseimage

* hdiutil attach /tmp/Yosemite.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build

* rm /Volumes/install_build/System/Installation/Packages

* cp -rp /Volumes/install_app/Packages /Volumes/install_build/System/Installation/

* cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/install_build

* cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/install_build

* hdiutil detach /Volumes/install_app

* hdiutil detach /Volumes/install_build

* hdiutil resize -size `hdiutil resize -limits /tmp/Yosemite.sparseimage | tail -n 1 | awk ‘{ print $1 }’`b /tmp/Yosemite.sparseimage
(NOTE: you may have to re-type the single quotes around { print $1 } due to “corrections” that are done.  I used these notes to create a Yosemite DVD by copy-pasting and I had to do this.)

* hdiutil convert /tmp/Yosemite.sparseimage -format UDTO -o /tmp/Yosemite

* rm /tmp/Yosemite.sparseimage

* mv /tmp/Yosemite.cdr ~/Desktop/Yosemite.iso

After performing the above commands one by one, an ISO will exist on your desktop named Yosemite.iso.

To burn the DVD, right-click on yosemite.iso, and open with Disk The Disk utility application will open, and you can select yosemite.iso on the left-side, and click “Burn” on the top bar, and follow the pop-ups.