I looked to see if this issue has been posted, but I couldn’t find it.
My iMac is set to shut down at a certain time every day but the shutdown is often interrupted by the message “There is a user sharing this computer. If you shut down they will be disconnected”.
I don’t care if any connected computers are disconnected, so can we write a script that runs in the background (or starts just before my shutdown time) that will answer the Shutdown dialog, thereby allowing the Shutdown to continue ?
If disconnecting the connected computers is easier to script, that would be ok, too.
This is a shot in the dark but the manual states that shutdown -k kicks everybody out, except for the local accounts, so maybe you could try to incorporate the line below before you execute your “real shut donw sequence?”
do shell script "shutdown -k"
Enter man -s8 shutdown in a terminal window to read more .
Thanks, I’ll look into this… But question… to clarify “the local accounts” - would that include any other computer connected to my iMac on the same network? Because there are no other computers connecting to the iMac except my other computers on the same network.
By local accounts I mean accounts local on your machine.
And please do try
do shell script "sudo -k " with administrator privileges
Thanks for telling me kel!
If this turns out to be a hindrance for the poster, but the sudo -k solution seem to be the right one, I’ll make something that lets it pass through, by creating a executable with root rights (setuid).
I have made a launchd plist for you, but you’ll have to read up on launchctl by yourself. The launchd.plist, with the conformant name you choose, should be saved in /Library/LaunchAgents.
The format of the calendar interval, which is quite flexible, is specified in either man cron, or man crontab.
[code]<?xml version="1.0" encoding="UTF-8"?>
Program
/sbin/shutdown
ProgramArguments
-k
now
RunAtLoad
[/code]
You'll probably also have to make root the owner of the plist file. And I haven't tried this, I leave it up to you to get it working, for instance, maybe the integers that holds asterisks, should be changed to for all what I know.
Edit
It does strike me, that if cron is accessible, and has the property still, that it doesn’t execute missed jobs, due to system sleep, then cron is better suited for tasks such as this.