LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 01:29 AM   #1
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 504

Rep: Reputation: 31
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, 01:51 AM   #2
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: RHEL/Ubuntu/Debian/Fedora/Centos/K3OS
Posts: 1,159
Blog Entries: 4

Rep: Reputation: 149Reputation: 149
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



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 03:56 PM
Solais 10 ssh session disconnect randomly LinuxLover Solaris / OpenSolaris 3 02-25-2010 05:05 PM
Session disconnect causes thread freeze brodsky99 Linux - Newbie 1 10-07-2008 08:13 PM
Session Disconnect fuldagap Linux - General 0 11-15-2005 10:11 PM
Truncate A File Dovetails Linux - Newbie 2 10-22-2005 06:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:39 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
Open Source Consulting | Domain Registration