LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-07-2010, 02:29 AM   #1
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 484

Rep: Reputation: 30
How to truncate a file and disconnect a session !


Dear Friends,

I have two questions :

1) Is it possible to truncate the file content , not to drop the file ? i.e, I want to just delete a file's content only, not to drop the file .

2) I can find the connectd user using command 'w' or 'who' . Now How can I force disconnect a session from the list of 'w'/'who' command ?

Waiting for kind reply ... ...
 
Old 10-07-2010, 02:51 AM   #2
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,138
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
Code:
1. echo > file1
2. If user is connected via ssh :
Quote:
Do "kill <pid>" where pid is any process from their session (found by typing 'w')
ps -ax to find the pid of the sshd session, and kill it.
Code:
for i in `ps aux | grep user | grep -v grep | awk '{print $2}'`; do kill -9 $i; done;
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp truncate text file busy - copying file is not a running binary jetberrocal Linux - Server 3 06-24-2010 04:56 PM
Solais 10 ssh session disconnect randomly LinuxLover Solaris / OpenSolaris 3 02-25-2010 06:05 PM
Session disconnect causes thread freeze brodsky99 Linux - Newbie 1 10-07-2008 09:13 PM
Session Disconnect fuldagap Linux - General 0 11-15-2005 11:11 PM
Truncate A File Dovetails Linux - Newbie 2 10-22-2005 07:58 PM


All times are GMT -5. The time now is 05:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration