Automator – How to Mount Network Share on a Schedule

automatorfile-sharingnas

I have two macs, that need to mount each other's respective network shares but also both need to restart every night.

The trouble is, neither computer can mount the other until the other is fully booted up with the volume ready.

How can I solve this without needing to use a paid 3rd party application?

I did find this question which is asking about a very similar need, but the top answer doesn't work because the user will always first be prompted to select the share they want to mount and this needs to happen unattended in the middle of the night.

If I can schedule the mountings, then each computer can just unmount the volume in question and restart (easy to do in Automator), and then some time later after both machines will easily be ready, re-mount their needed shares.

So, how can I simply schedule each machine to mount the required remote share, at a specified time?

Best Answer

Believe I have solved this on my own. The part that wasn't working for me, was that Automator would always prompt me to select the specific share/folder I wanted to mount. Turns out I missed the obvious - specify the folder in the path provided in an Applescript! Like so:

tell application "Finder"
    if not (disk "FolderName" exists) then
        mount volume "afp://MyMac.local/FolderName"
    end if
end tell

Now I'm just going to put a few-minutes pause before this command, and set the resulting Automator app to run at startup. If both machines unmount the remote volumes and reboot at the same time each night, all should be well with the world. In order to schedule the execution of my automator commands, I'm just using the Calendar's ability to launch a file on alert.