I'd like my home GNU/Linux server to power down after 30 minutes of inactivity. For "activity", I'm thinking
- any new [CUPS] print jobs
- any requests to a locally running Apache server
- any activity over SSH except for failed logins
If any of these things occur, I'd like the 30-minute countdown to reset.
The first two seem pretty doable. I could just write a little long-running Python or Bash program that
- waits patiently for 30 minutes to issue
shutdown -h now
- monitors the filesize of CUPS and Apache access logs, resetting the timer when any file growth is detected
But I'm not really sure about keeping track of SSH activity. Is there a somewhat easy way to do that? I'm not really interested in dealing with libpcap or whatever, unless it is pretty straightforward.
Another thought that strikes me is that this might be generically useful, so maybe I'll make something extensible and release it as Free Software.
I'm not sure if it is relevant, but the server in question is running Ubuntu 10.04.4 LTS.
My question is similar to this one, except for the activity detection.