We no longer offer ftp downloads. If there is a file you need referenced here, please contact me by email and I will get it to you.
I've never been happy with idleout. It is a shell script, so you can modify it for your own needs, but it lacks many features that people want, and can often be wrong about whether or not a user truly is idle. It is also not particularly easy to modify for complex uses.
A better program is nidleout by John Dubois. This has many more features, and is far less apt to be wrong about idleness, but it still has problems. For one thing, it's written as a ksh script, and it pushes the capabilities of ksh fairly hard, so it too isn't all that easy to modify. Further, it (by design) simply ignores certain processes that it cannot be sure about, and that list includes console X sessions.
There are also commercial solutions. Computronics Logmon is product that doesn't have the limitations of idleout and offers extensive configuration capability.
So, I started thinking about how I could really tell if someone was idle, and it struck me that /etc/crash could give me most of what I needed. The resulting program is presented here. It isn't perfect, but it seems to have some capabilities lacking in other methods, so it might work for you.
Diller Ryan noted this bug: I tried your PIDDLE.PL program. I don't think you can do anything about it, but there seems to be a problem in the perl library popen code. After running for a day, the program apparently used my quota of processes. 'ps' displayed a huge list of zombies, which I believe were the residue of your periodic queries. It seems like there should be a 'wait' in the the library code. Have you noticed this before? I doubt it's anything to do with the spawning of "ps" and "crash". A zombie is the result of a parent process that dies before its children, and piddle doesn't die. Rather I suspect it has to do with the ordering of the kills, but it's still something that may need work.
This uses a configuration file (actually, it can use several different configuration files, but we'll get to that later). Here's a sample file:
# piddle configuration file # root on console (secure room) gets 60 minutes root:tty01=60 root:tty02=60 root:tty03=60 root:tty04=60 # root on any other terminal only gets 10 minutes root:*=10 # tty2a is in open area, 10 minutes only *:tty2a=10 # tony gets to stay in a long time tony:*=9999 # otherwise, anybody else gets 15 minutes *:*=15 # exit after 8 hours # this is so you can have different rules files for different # times of days, days of the week, etc. RUNTIME=480 # processes that need to be ignored because they tick even when idle TICKS=xdt3_binary TICKS=Xsco # using long process listing, bypass users running IGNORE IGNORE=checks IGNORE=cash -d update
You can probably figure most of this out by yourself, but some explanation may be needed for some of it.
TICKS, for example, are programs that will have "activity" in /etc/crash even when the user really is idle. A good example of that is a user running the gui on the console: Xsco and xdt3_binary will appear to be busy even when the user really isn't. By setting TICKS lines equal to these programs, we can idle those users out (note that nidleout handles these "event driven" programs by ignoring them entirely, and that idleout sees such users as idle even when they are not).
IGNORE is for the case when you definitely do not want to kill a user running a particular process. The string argument will be compared to the long argument from ps, not the command argument (note the difference between
ps -o pid= -o args=
and
ps -o pid= -o comm=
if that confuses you).
RUNTIME is so that you can have different rules for different times of day, different days of the week, etc. Just fire "piddle"'s off from crontab, giving different configuration files as arguments, and setting RUNTIME so that one exits before the other starts.
Piddle is designed so that you can test it without actually affecting any user. If the debug level is set to "1" (as it is by default), debugging output will be written to /tmp/piddle.debug, and this will include information about the users and processes that would be killed if debug were set to "2" or were not set at all.
One note: the accuracy is rather granular: someone supposed to get 15 minutes of grace may get close to 30 under some conditions. I haven't felt that is important.
Please do test this before turning it loose. If you find improvements that could be made, please report them to me.
Download piddle.pl.
(c) November 1998 Anthony Lawrence. All rights reserved.
/Unixart/piddle.html copyright All Rights Reserved
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar