![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
| View Poll Results: Was this helpful? | |||
| Yes |
|
0 | 0% |
| No |
|
2 | 100.00% |
| Maybe |
|
0 | 0% |
| Dont know |
|
0 | 0% |
| Voters: 2. You may not vote on this poll | |||
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Active / Non Active users ? | varungupta | UNIX for Advanced & Expert Users | 3 | 05-11-2008 08:00 PM |
| Killing parent shells from subshells (KSH) | rockysfr | Shell Programming and Scripting | 4 | 06-28-2007 04:53 PM |
| AIX timezones - a way around rebooting? | willwork4foo | AIX | 2 | 10-23-2006 06:10 AM |
| AIX Constant Rebooting | AIXNEWBEE | AIX | 4 | 10-30-2005 02:33 PM |
| soft rebooting | nattie_h | UNIX for Dummies Questions & Answers | 5 | 03-06-2002 12:15 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi All,
This may seem to be a very strange request but here is what I am trying to do 1. run a clean up script for my product which will basically remove the directories, entries in the /etc/profile After that I need to know who all are logged on to the Unix server and log them all off. it so happens that everyone just logs in to our test Unix servers using the root user, so I have to forcibly close their shells and reopen a new shell which(hopefully) will pickup the new and modified profile Is there a way to do this through a shell script? I am no guru at Unix as you probably can see very clearly...but this piece of code will help me go a long way ahead in the project that I am currently working with Regards, Deekshit |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
First the good news: if you are root yourself (that is: have the necessary privileges) you can close all the other users shell (including roots sessions) exactly the way you want.
I am no Linux specialist and the output (and the options) of the used commands differ somewhat from UNIX derivate to UNIX derivate so i can tell you only generally how that is done: Have a look at the "who" command (enter "man who") which will provide you with all the process IDs (PIDs) of the other shell sessions. Use some sort of text filter ("sed" or "awk" usually) to trim that down to a bare list of process IDs and use "kill" on each of these processes to end it. That will effectively log off the user. Here is a schema of such a script: Code:
who <some options> | sed <some trimming commands> | while read PID ; do
kill -9 $PID
done
bakunin PS: may i ask which purpose the poll serves? |
|
#3
|
|||
|
|||
|
Quote:
i have no idea. it asked me if I wanted a poll and I went ahead with it. I will try your code and update this thread if it works the way I want it to. Regards, Deekshit |
|
#4
|
|||
|
|||
|
kill -9 is probably (as they say) overkill. The general suggestion would be to just kill or perhaps kill -2 and only if those don't work use kill -9
See also "useless use of kill -9" - Google Search On Linux who -l lists the PID in the sixth field, so you can do it like this: Code:
kill `who -l | awk '{ print $6 }'`
|
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|