Solved

Killing all users via cron

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this tutorial I will explain how to make squid prevent malwares in five easy steps: Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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.

746 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

11 Experts available now in Live!

Get 1:1 Help Now