Solved

Killing all users via cron

Posted on 2003-12-02
5
344 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now