Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-01-2010, 09:05 AM
|
#1
|
Member
Registered: Feb 2010
Posts: 39
Rep:
|
logged users without processes?
Hi,
curenntly I try to write a script which would kill processes of users who are not logged in.
My approach is to find out what users are logged in and then kill processes of all nonsystem users who fail the test of being logged.
I use `w` for finding all logged in users, but apparently there are users on the list which `w` gives me who own absolutely no process in the output of `ps aux`.
Some questions regarding this:
- How do I log off those users, since killing their processes wont work (since they own no processes)?
- How could it had happen?
- Is there a better way to actually find out what users are really logged in?
Thanks in advance,
chris
|
|
|
11-02-2010, 02:14 AM
|
#2
|
Senior Member
Registered: Apr 2007
Location: Bangalore, India
Distribution: RHEL,SuSE,CentOS,Fedora,Ubuntu
Posts: 1,386
Rep: 
|
|
|
|
11-02-2010, 06:25 AM
|
#3
|
Member
Registered: May 2010
Posts: 36
Rep:
|
paliga, if users have no processes, they cannot be logged in.
when a user logs in, a note is made in a file, such that programs like "w" know who's logged in. When a user is logged out the system attempts to note that into that file too. However this requires a few more cpu cycles from their "login" program. If for instance a program (script) kills their programs, the "note that we're now logged out" may have become impossible. So, "w" might show someone logged in on say "ttyp4", but if no program is running that ttyp4 is "free" and may be taken by then next user to log in. At that point in time the outdated information will be overwritten.
In short: don't worry about it. If you can't find any processes, they are not actually logged in.
Oh, and besides... It works much better if you just ask your users not to leave any programs running, and tell them you'll take measures if they do. The way you're doing things now will trigger an arms race between you and the students leaving you as the loser. (there is almost always a student smarter than you).
|
|
|
11-02-2010, 02:04 PM
|
#4
|
Member
Registered: Feb 2010
Posts: 39
Original Poster
Rep:
|
thanks for your answers!
last is much more handy than w or who... thanks a lot...
I was just wondering... Im far away from starting any arms races... ; )
|
|
|
11-02-2010, 02:05 PM
|
#5
|
Member
Registered: Feb 2010
Posts: 39
Original Poster
Rep:
|
thanks for your answers!
last is much more handy than w or who... thanks a lot...
I was just wondering... Im far away from starting any arms races... ; )
|
|
|
All times are GMT -5. The time now is 06:37 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|