?
Solved

Killing all users via cron

Posted on 2003-12-02
5
Medium Priority
?
351 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 1000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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 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…
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.
Suggested Courses

719 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