After installing OpenCore Legacy Patcher on my Mac mini, it has been flawlessly running Monterey for several months, with the exception that screensharing stops randomly. To get around this, I’ve been making an ssh connection to the Mac mini and then run this command:
sudo launchctl kill KILL system/com.apple.screensharing
Rather than having to run this command manually, automate it with launchctl to run as a LaunchDaemon every day at 2 am:
- Touch a .plist file in the following directory using this command in Terminal:
sudo touch /Library/LaunchDaemons/com.screensharing.restart.plist
- Edit the .plist file by executing this command in Terminal:
sudo pico com.screensharing.restart.plist
- Copy text from this file and paste it into your .plist file.
- Save your .plist file by pressing the “control” and “x” keys and choose press “y” and “return”.
- Load the .plist into launchctl using the following command in Terminal.app:
sudo launchctl load /Library/LaunchDaemons/com.screensharing.restart.plist
- If the LaunchDaemon loaded, it should appear in the list produced by this Terminal command:
sudo launchctl list
- To unload the LaunchDaemon we created above, execute the following command in Terminal:
launchctl unload /Library/LaunchDaemons/com.screensharing.restart.plist
- Finally, if you wish to completely remove this command from your machine, delete the .plist file with this command:
sudo rm /Library/LaunchDaemons/com.screensharing.restart.plist
Worth noting, this LaunchDaemon executes as the “_www” user, so it should run whenever the Mac mini has booted Monterey. Will keep you posted how this works and if I need to increase the frequency. Ultimately, I’d like to find out what is causing the screensharing crash, but that may be above my abilities.