Solved

Killing all users via cron

Posted on 2003-12-02
5
346 Views
Last Modified: 2010-04-21
Hello, Redhat 6.2 - 7.2  
Is there a built in way of having the system log off all users (telnet) at say midnight? If not where could i find a script that would do this for us? Thanks
0
Comment
Question by:robids
  • 2
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 250 total points
ID: 9859846
Untested, by the line below should sent a kill -9 (the KILL signal) to PIDs (column 2, via awk) of any bash shell processes), not sure whether this would afect any other processes runing via a bash shell.

kill -9 `ps -aux |grep bash|awk '{print $2}'`

to do it via cron
0 0 * * * /usr/bin/kill -9 `ps -aux |grep bash|awk '{print $2}'`

0
 
LVL 5

Expert Comment

by:paulqna
ID: 9860211
I would not recommend to kill all bash processes, that will not guarantee all "telnet" users are gone, or lost of data due to killing system scripts/apps.

I would suggest to restart the telnet (inetd) service from cron.

What do you use, xinetd ?
0
 
LVL 18

Expert Comment

by:liddler
ID: 9860401
Stopping telnetd / inetd doesn't kill any current sessions, it just prevents new ones.
0
 

Author Comment

by:robids
ID: 9860606
Stoping xinetd does not drop the telnet session. it only prevents new logins
0
 

Author Comment

by:robids
ID: 9860936
You were right that it would not get the bash applications running under it, but by simply changing to
 kill -9 `ps -aux |grep pts/|awk '{print $2}'`

This got every thing associated to the telnet. I have still to test more. Also, I had to suppress errors on cron not being able to find all processes since things die in different orders.
Thanks
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question