Solved

Killing all users via cron

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Upgraded from Debian 7 to 8.7 and got black screen 20 122
what do I need to host my own web sites? 13 85
Linux kernel panic ext3-fs error 14 75
phpmyadmin memory error 55 94
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 …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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.

734 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