Results 1 to 2 of 2
i need to create script which will shut down rhel6 workstations if it is not used for 30min for that i need a command which will give me system idle ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-16-2011 #1
- Join Date
- Jun 2010
Help !!!! Needed to find system idle time
i need to create script which will shut down rhel6 workstations if it is not used for 30min for that i need a command which will give me system idle time i.e. that time in which system has not received any mouse or keyboard interrupts.
i think gnome desktop is also doing same thing, if keyboard/mouse interrupts is not received for some time screen will be locked.
its really urgent. !!!!
- 09-16-2011 #2
- Join Date
- May 2011
well, you can just run a loop and check for the elapsed time of the screensaver (if/when it is found running), e.g. (untested):
#!/bin/bash while :; do pid=$(/sbin/pidof gnome-screensaver) if [ $? -eq 0 -a -n "$pid" ]; then etime=$(ps -o etime --no-heading -p $pid) echo "Screensaver (pid $pid) is running, elapsed time: $etime" fi sleep 1 done
but i think this solution would only work if someone was logged onto the desktop first (and had a screensaver configured to run), versus the computer just sitting at the graphical login prompt. but maybe that's what you want...