To limit macOS Screen Sharing to business hours, install two launchd system daemons with StartCalendarInterval arrays: one loads Apple's Screen Sharing daemon at 09:00 Monday to Friday, the other unloads it at 18:00. Test both the same day with launchctl kickstart -k. The complete plists and the test procedure are below, and setup takes about fifteen minutes.
Read the safety note first. Figment has not published which remote desktop client or protocol its own connection uses. If your connection to the Mac depends on macOS Screen Sharing, disabling it at 18:00 also cuts you off. Before you rely on the schedule, confirm the connection details in your Figment account and make sure you keep a way back in, such as SSH, which every Figment plan includes.
Why restrict Screen Sharing to business hours?
A stopped Screen Sharing daemon accepts no new VNC connections, so an off-hours attempt gets "unable to connect" instead of a login prompt. With a strong password this shrinks the brute-force window from 168 hours a week to about 45 (9 hours × 5 days). It also makes your logs easier to read: any connection reaching the Screen Sharing subsystem outside the window is anomalous by definition. On a rental it has a cost benefit too, because contractors who cannot connect at night cannot leave long CPU jobs running overnight.
How do I turn Screen Sharing on and off from the Terminal?
Screen Sharing is a system LaunchDaemon (com.apple.screensharing) with a plist at /System/Library/LaunchDaemons/com.apple.screensharing.plist. Apple documents the toggle in Turn screen sharing on or off on Mac. From the Terminal:
# Enable Screen Sharing
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
# Disable Screen Sharing
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
On macOS 13 Ventura and later Apple prefers the domain-aware form:
sudo launchctl bootstrap system /System/Library/LaunchDaemons/com.apple.screensharing.plist
sudo launchctl bootout system/com.apple.screensharing
Both forms still work on current macOS; use whichever matches the version on your Mac. Starting with macOS 12.1 Apple also tightened TCC gating around Screen Sharing. On some configurations launchctl only starts the daemon cleanly after the service has been enabled once in System Settings → General → Sharing → Screen Sharing. If your scheduled jobs refuse to start it, flip the toggle on once by hand, then flip it off and let the daemon take over.
Verify the current state:
sudo launchctl list | grep screensharing
# A line with a PID means the daemon is running.
# A line with "-" means it is loaded but not currently running.
# No line at all means it is not loaded.
How do I schedule the enable and disable jobs?
Use StartCalendarInterval, a dict (or array of dicts) with keys Minute, Hour, Day, Weekday and Month; omitted keys act as wildcards. It is documented in Apple's Creating launchd Jobs and the launchd.plist(5) man page. Weekday is 0 to 7, where 0 and 7 both mean Sunday, so Monday to Friday is 1 through 5, and a range needs one dict per day.
Both plists belong in /Library/LaunchDaemons/ and run as root, which launchctl needs to start or stop a system service.
/Library/LaunchDaemons/com.company.screensharing-enable.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.company.screensharing-enable</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>load</string>
<string>-w</string>
<string>/System/Library/LaunchDaemons/com.apple.screensharing.plist</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict><key>Hour</key><integer>9</integer><key>Minute</key><integer>0</integer><key>Weekday</key><integer>1</integer></dict>
<dict><key>Hour</key><integer>9</integer><key>Minute</key><integer>0</integer><key>Weekday</key><integer>2</integer></dict>
<dict><key>Hour</key><integer>9</integer><key>Minute</key><integer>0</integer><key>Weekday</key><integer>3</integer></dict>
<dict><key>Hour</key><integer>9</integer><key>Minute</key><integer>0</integer><key>Weekday</key><integer>4</integer></dict>
<dict><key>Hour</key><integer>9</integer><key>Minute</key><integer>0</integer><key>Weekday</key><integer>5</integer></dict>
</array>
<key>StandardOutPath</key>
<string>/var/log/screensharing-schedule.log</string>
<key>StandardErrorPath</key>
<string>/var/log/screensharing-schedule.log</string>
</dict>
</plist>
/Library/LaunchDaemons/com.company.screensharing-disable.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.company.screensharing-disable</string>
<key>ProgramArguments</key>
<array>
<string>/bin/launchctl</string>
<string>unload</string>
<string>-w</string>
<string>/System/Library/LaunchDaemons/com.apple.screensharing.plist</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict><key>Hour</key><integer>18</integer><key>Minute</key><integer>0</integer><key>Weekday</key><integer>1</integer></dict>
<dict><key>Hour</key><integer>18</integer><key>Minute</key><integer>0</integer><key>Weekday</key><integer>2</integer></dict>
<dict><key>Hour</key><integer>18</integer><key>Minute</key><integer>0</integer><key>Weekday</key><integer>3</integer></dict>
<dict><key>Hour</key><integer>18</integer><key>Minute</key><integer>0</integer><key>Weekday</key><integer>4</integer></dict>
<dict><key>Hour</key><integer>18</integer><key>Minute</key><integer>0</integer><key>Weekday</key><integer>5</integer></dict>
</array>
<key>StandardOutPath</key>
<string>/var/log/screensharing-schedule.log</string>
<key>StandardErrorPath</key>
<string>/var/log/screensharing-schedule.log</string>
</dict>
</plist>
Set ownership and permissions before loading. LaunchDaemons must be root-owned and not group- or world-writable, or launchd refuses them:
sudo chown root:wheel /Library/LaunchDaemons/com.company.screensharing-*.plist
sudo chmod 644 /Library/LaunchDaemons/com.company.screensharing-*.plist
sudo launchctl bootstrap system /Library/LaunchDaemons/com.company.screensharing-enable.plist
sudo launchctl bootstrap system /Library/LaunchDaemons/com.company.screensharing-disable.plist
Which timezone do the jobs use?
launchd fires calendar jobs in the Mac's system timezone, so 09:00 and 18:00 mean the Mac's clock, not your team's. Figment's Macs are in US East, so a team elsewhere should set the timezone first:
# Example: UK business hours
sudo systemsetup -settimezone "Europe/London"
sudo systemsetup -gettimezone
sudo systemsetup -listtimezones prints the valid identifiers. After changing the timezone, run bootout and bootstrap on both plists again so launchd recalculates the next fire time.
How do I test the schedule without waiting for tomorrow?
Use launchctl kickstart, which runs a loaded job immediately. The -k flag kills a running instance first, which is fine because each job is a short-lived command.
# Run the disable job now
sudo launchctl kickstart -k system/com.company.screensharing-disable
sleep 2
sudo launchctl list | grep screensharing
# Expect: "-" (loaded, not running) or no line at all
# Run the enable job now
sudo launchctl kickstart -k system/com.company.screensharing-enable
sleep 2
sudo launchctl list | grep screensharing
# Expect: a line with a PID
Then test from a real VNC client in each state. A refused connection while the daemon is stopped is the behavior you want.
What if someone needs access outside hours?
Enable Screen Sharing by hand and log the event so the record stays honest:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
printf '%s MANUAL_OVERRIDE_ENABLE by=%s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$USER" \
| sudo tee -a /var/log/screensharing-schedule.log >/dev/null
# When done
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
printf '%s MANUAL_OVERRIDE_DISABLE by=%s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$USER" \
| sudo tee -a /var/log/screensharing-schedule.log >/dev/null
The scheduled jobs re-assert the correct state at the next fire time, so an override cannot silently persist into the next morning.
How do I review off-hours connection attempts?
The plists write their own output to /var/log/screensharing-schedule.log. To capture connection events, stream the Screen Sharing subsystem to a review log:
sudo log stream --predicate 'subsystem == "com.apple.screensharing"' \
--style compact >> /var/log/screensharing-attempts.log &
Attempts that arrive while the daemon is stopped never reach the Screen Sharing subsystem; they land in the network layer. For a simple check that the schedule ran, add a third launchd job that runs netstat -an | grep '\.5900 .*LISTEN' every 15 minutes and writes a line with the result. If port 5900 is listening at 02:00, the disable job did not fire.
Do you need administrator access for the access schedule?
Any Figment plan gives you administrator access to your own Mac or VM, which is what writing to /Library/LaunchDaemons/ and running sudo launchctl requires. The Intel Mac VM ($2 a day, $25 a month) is enough to build and test the schedule. Use the Apple Silicon Mac VM ($6 a day, $39 a month) or the Dedicated M4 Pro 48 GB ($349 a month, or $299 a month on a 12-month term) when the contractors you are scheduling also need current Xcode or a whole Mac to themselves.
Related reading