1831343 Members
3101 Online
110024 Solutions
New Discussion

How to log out all users

 
GNOM
Frequent Advisor

How to log out all users

Hi,
How can I log all connected users out, on a hp 9000 server running HP-UX 11.11

thanks for your help
6 REPLIES 6
Pete Randall
Outstanding Contributor

Re: How to log out all users

Shutdown to single user mode.


Pete

Pete
GNOM
Frequent Advisor

Re: How to log out all users

Hi,
I have to do it without changing the run level
because there many processes the should not be killed. The server run a package witch should not be stoped

thanks
Pete Randall
Outstanding Contributor

Re: How to log out all users

Then you'll have to enable the NOLOGIN feature of /etc/default/security (see man security), touch the /etc/nologin file, and kill off the user's sessions. I've attached a little script that will kill the user's sessions (you will have to edit this to grep out the processes you don't want killed), but I would consider this riskier than just shutting down.


Pete

Pete
Mahesh Kumar Malik
Honored Contributor

Re: How to log out all users

Hi

You have to use nohup with users kill command. Please visit following link:

http://docs.hp.com/en/B2355-90690/nohup.1.html

Regards
Mahesh
Muthukumar_5
Honored Contributor

Re: How to log out all users

You can do it as,

# wall
All users are going to be killed.
# sleep 5
# who -u | awk '!/system console/ { print $7 }' | xargs kill -9

hth.

Easy to suggest when don't know about the problem!
Bill Hassell
Honored Contributor

Re: How to log out all users

Just a big precaution: NEVER use kill -9, especially on a production server. kill -9 almost always guarentees data corruption for database processes and leaves shared memory marked as used when the prcoess disappears. ALWAYS use kill -15, then check again with who -u to see users that are still left. Examine what a specific user is doing with this command:

# UNIX95= ps -f -H -u user_name

(note that UNIX95= will enable the -H option in ps) This shows the hierarchy of processes. Try a kill -15 on the highest level process, and if that doesn't work, try it on the second level. When kill -15 doesn't work, one or more of the processes are not running (ie, waiting on I/O) and if the I/O never completes, the process will never see the kill command.

You can also try the kill -1 command in case a process is trapping the normal kill signal. kill -1 is the hangup signal which tells the process that the connection has been removed. If you're sure that the processes a stuck user is running will not be a problem to forcibly kill, then you can use kill -9 but then check on shared memory (ipcs -bmop or ipcs -bmopa for more details) to see if orphaned segments need to be removed.


Bill Hassell, sysadmin