Forced user idle timeout for labs

New Contributor II

We used something called Power Manager in the past, which we configured to pop up multiple warnings to user before the machine would force them off if they idled to long. We use Deepfreeze which makes warning the users a big deal before it deletes any files they have open.

I found this IdleLogout on here recently in past threads which seemed to be a perfect free replacement, but in my testing, it doesn't seem to function on Mojave.

Already tried the log off user policy in JAMF, gets stuck with opened files like word docs.

Any ideas?


New Contributor III

I'd be interested in a solution as well, we have a workflow working for our PC machines that will force them out with a countdown so they have an opportunity to cancel the force log off, would like something similar for our Macs in our labs.


Contributor III

Also interested. One of my labs uses Word a ton, they often forget to sign out. After a week, I had 18 logged in users all with open docs.


Has anyone come up with a solution for this? Mojave or Catalina, lab environment with binded machines. If users do not logout of software such as Word the user account is tied to the user and the only fix I see is a cold reboot of device.

New Contributor II

Stolen bits from here and there plus some of my own...

exec 2>&1

# Init vars

# Get the logged in user
loggedInUser="$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }')"

if [[ "$loggedInUser" == "" ]]; then
    # no one is logged in so there's no need to force a logout
    echo "No one is logged in...exiting..."
    exit 0

# Get idletime
idleTime=$(ioreg -c IOHIDSystem | /usr/bin/awk '/HIDIdleTime/ {print int($NF/1000000000); exit}')

if (( idleTime > 21600 )); then
    echo "$loggedInUser is logged in and Mac has been idle for $idleTime seconds..."
    echo "Maximum idle time is 21600 seconds (6 hours)...logging user out..."
    pkill loginwindow
    echo "Currently logged in user $loggedInUser has been active within the past 6 hours...exiting..."

exit 0