Force Restart After Inactivity

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-03-2021 12:43 PM
Hi all,
I have a need for a script that forces Macs to restart after 10 minutes of inactivity. There would need to be a warning that pops up as well, say after 8 minutes of inactivity to give a user a heads up that a restart is coming. Anyone know of such a script or way to provide such a feature that is already in existence?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-04-2021 06:12 AM
You may be able to adapt our auto logout daemon; https://github.com/UoE-macOS/lab/blob/master/ed.dst.labs-auto-logout-py.plist (daemon) https://github.com/UoE-macOS/lab/blob/master/labconfig-auto-logout.py (script, there may be an older shell version of the script too) to perform this task...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-21-2021 10:59 AM
Thank you @dsavageED . If you are adding this to Jamf as a script that runs at a Login, how do you get it to trigger on a recurring basis after a user logs in? From looking at the script it looks like it exits if the idle time is detected to be less than 1.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-22-2021 04:33 AM
The script as it stands is called by a daemon, both are meant to be locally installed on the system. It isn't something that is easy to do just running off a login hook...
To run from a login hook, you could generate a script and then launch it in the background with a loop that sleeps for 30 mins or something, but in that case you could just run the script at check-in on the Mac. Short answer is I don't think login is the right place to try and run this from.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-28-2022 11:32 AM
@dsavageED have you upgraded this script to work with Python 3 in Monterey? I have attempted to do so, but am having trouble getting Jamf process to quit to allow the logout.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-04-2021 10:53 AM
May I know what are you trying to achieve as restarting Mac when it is inactive for 10 minutes will give bad user experience.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 08-04-2021 10:57 AM
Sure @Samstar777 , if you are curious it is for a college library, and is meant to prevent a student walking way while leaving browsers logged into a website, or other personal data on the machine accessible to the next student using the machine.
We aren't currently set up to have our students log into a Mac with their school IDs so, this is an alternative.
Our Macs are frozen with Deep Freeze for Mac, so a restart takes the Mac back to a clean slate.
Our Windows machines do the same thing, but log the student out rather than restart the Mac, as our students do log into these devices.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 09-21-2021 11:26 AM
You may explore below link once
https://github.com/rosedu/Pidgin/blob/master/pidgin/gtkidle.c
-Samstar777
