Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-08-2010, 02:01 AM   #1
LQ Newbie
Registered: Aug 2010
Posts: 2

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

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

Old 12-08-2010, 03:15 AM   #2
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:

> 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:
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:

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

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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, 05:11 AM   #4
LQ Newbie
Registered: Aug 2010
Posts: 2

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

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.


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

All times are GMT -5. The time now is 12:54 PM.

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