Something like this little for loop would suffiice:
for user in `who -u |egrep -v root |awk '{print $7}'
do
kill $user
done
This is a simple script which kill each users parent process i.e. login PID. The egrep -v means ignore the root user logins and print $7 prints out, as input the PID of user login.
I agree that putting a kill command in a script can be dangerous, so use caution with it.
We would typically have 400 to 500 users logged in, each with two processes running, as they attached to the application. After "wall"ing to users to log off, then "echo"ing a statement into /etc/nologin to prevent further logins from occurring, you can use a command line entry if the users have a process that is common. For example, if they all attach to an application called APP1, but you don't want to kill anything that is being run by root or perhaps an APP1 admin ID, you can do something like:
FIRST TIME AROUND DO THIS TO BE ABSOLUTELY SURE OF WHAT YOU ARE GOING TO KILL:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.