Chris Dzombak

Keeping a SMB share mounted on macOS (and alerting when it does down)

On my primary Mac Studio desktop, I like to keep 2 Samba shares from my home server/NAS mounted all the time. These mounts can be interrupted by network glitches, power outages, and the like, so I needed a solution that could remount them when necessary and would alert me if they went offline for more than a few minutes.

The solution uses a combination of launchd, AppleScript, Uptime Kuma, and runner (my task runner/retrier/failure notification tool).

Initial connection

First, mount the share via the Finder’s “Connect to Server” dialog (which you can open from the Finder via ⌘K).

Finder SMB connection dialog

If prompted, allow the Finder to save the share’s password. This will allow a launchd job to remount it automatically when necessary.

Maintenance script

Create a script that:

I do this using this script, ~/code/

#!/usr/bin/env bash
set -euo pipefail

[ -f /Volumes/general/.liveness.txt ] || osascript -e 'mount volume "smb://cdzombak@jetstream.dzhome/general"'

This script checks that the share is mounted by checking for the (empty) file .liveness.txt in it, and if it’s missing it uses AppleScript to tell the Finder to remount the share.

launchd job & monitoring

Finally, we’ll run that script every minute using launchd. This job definition runs the script, and it uses runner to notify an Uptime Kuma push monitor when the script succeeds.

If the script fails — meaning the share is missing and remounting it failed — Uptime Kuma will notify me via email.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">