LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 12-08-2010, 01:01 AM   #1
s.adarsh
LQ Newbie
 
Registered: Aug 2010
Posts: 2

Rep: Reputation: 0
opening text file after doing /dev/null


Hi,
I ran a program that writes continuously from 1 every line.
After some time I ran '/dev/null > temp'
Problem1: bash: /dev/null: Permission denied
(Yes, the permissions of /dev/null are correct ... crw-rw-rw-. I removed and created it again, but no change)
I used 'cat temp' to see the contents and first few lines deleted (working correctly).
Problem2: I can't open the file (with double click or with any graphical editor like gedit)

Apart from these problems, I have another question... Is there a way to trim a active log file to say 80% without affecting any logs that server might be writing.

Thank you

Adarsh
 
Old 12-08-2010, 02:15 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
Problem 1

/dev/null is a device not a command, but is not even required for what you are doing as the remainder of the line is what is clearing the contents of temp:

Code:
> temp
Problem 2

As the file is being constantly written to, I am not suprised you are having issues opening the file with a graphical editor.

When I am looking at log files, I would tend to either cat the file or use tail -f:
Code:
cat temp
tail -f temp
To reduce the size of a file while it is still being used:

Either use > {file} this however *empties* the file completely (not reducing by 80%)
or move the current file to a new location:

Code:
mv temp temp.1
 
Old 12-08-2010, 03:26 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by s.adarsh View Post
Is there a way to trim a active log file to say 80% without affecting any logs that server might be writing.
Have you looked at what logrotate can do?
 
Old 12-08-2010, 04:11 AM   #4
s.adarsh
LQ Newbie
 
Registered: Aug 2010
Posts: 2

Original Poster
Rep: Reputation: 0
@Disillusionist
Even after the file is done with writing... it is not opening

@Catkin
Yes, read about it and it says with 'copytruncate' option it copies the original file and empties the file to zero. If possible I want to retain some recent data in that file.
 
  


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
/dev/null is a regular file Wynd Linux - General 2 01-24-2008 12:29 PM
What is meant by " file > /dev/null 2>&1 </dev/null " attockonian Linux - Newbie 5 06-30-2006 10:51 PM
Outputting Command Text to /dev/null rootking Linux - Software 4 12-19-2004 07:10 PM
What applicability of a file /dev/null ukrainet Linux - Newbie 1 12-01-2004 09:04 AM
Switch stdout between /dev/null and a file? gremlin2000 Linux - Newbie 1 06-01-2004 10:13 AM


All times are GMT -5. The time now is 04:19 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