Virtual file or memory?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Virtual file or memory?
# 1  
Old 08-06-2010
Virtual file or memory?

Hi Experts
I encountered a situation recently. I wanted to discuss here and understand the reason behind this. My scenario is something like this:

Code:
yes > temp  &

The above command keeps writing the output to the file temp. And this file keeps growing every second. And in the every passing second, the file system is slowly getting full. Now a user, user1, unknowingly deletes this file temp.
Code:
rm temp

Now user2 logs in, and realizes file system is getting full. He searches for all the big files and deletes them, still over a period of time, its getting full because the earlier process is still alive .

I have 2 questions.

1. The moment i kill the process "yes > temp", my file system size comes back to normal(in my actual case from 100 to 27) which makes me understand the process was writing somewhere. Once it got killed, the space got freed. Where was it writing at since the temp file does not exist?

2. The user1 having deleted the file temp, is there any way in which I can associate a file to the process now?


Please advice.

Guru.
# 2  
Old 08-06-2010
lsof

lsof will show you.. actually it would be a hidden file after deletion associated with that process.

---------- Post updated at 00:27 ---------- Previous update was at 00:09 ----------

refer Recovering Deleted Files With lsof — ServerWatch.com

Using that technique you will be able to find the file.
# 3  
Old 08-06-2010
The file is not truly deleted until all references to it are closed. Until then, it is kept on disk, generally inaccessible to anything except the programs that still have it open.

You should truncate logfiles instead of deleting them to clear space:

Code:
: > logfile

...will reset its size to zero, after which it will slowly fill up again as long as the program feeding it continues to write.
# 4  
Old 08-07-2010
@thegeek
Thanks for the very useful link. I got almost done what I wanted. However, once I got the process to write to a new file temp1, the file is not growing. Its constant with the same size as how it was at the time of restoring even though the process is still writing.

Also, when I go to the appropriate proc directory(/proc/<mypid>/fd/1), it still shows the output descriptor 1 being attached to my original output file temp, and not temp1.

@Corona668
Thanks for your reply . However, on trying your option, the file did get truncated, but it was not growing anymore. It was stagnant at size 0. Perhaps I am doing something wrong.

Guru.
# 5  
Old 08-07-2010
The program you're using won't reseek to the beginning of the file when its logfile is truncated, then. If it doesn't accept SIGHUP to tell it to reopen its logfiles, you may have to restart the process to safely clear its logfile.

You could also redirect its output into split -l 10000 instead of into a file. This will create many seperate files of 10000 lines each which you can delete individually, only the one not finished will still be held open.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Virtual Memory in UNIX

So, I would ask you a piece of advice about which books or titles could give me comprehensive information about virtual memory in UNIX. Especially, I would found out that virtual address translation corresponds structures of kernel! Thanks! (2 Replies)
Discussion started by: Fadedfate
2 Replies

2. UNIX for Dummies Questions & Answers

Virtual Memory

Hi, Can anyone please help me workout how much virtual memory I have running on a T2000 running Solaris 10. Thanks # df -h swap 3.5G 1.0M 3.5G 1% /etc/svc/volatile swap 3.5G 208K 3.5G 1% /tmp swap 3.5G 56K ... (2 Replies)
Discussion started by: jamba1
2 Replies

3. UNIX for Dummies Questions & Answers

cpu, memory and virtual memory usage

Hi All, Does anyone know what the best commands in the UNIX command line are for obtaining this info: current CPU usage memory usage virtual memory usage preferably with date and time parameters too? thanks ocelot (4 Replies)
Discussion started by: ocelot
4 Replies

4. AIX

ulimits max locked memory virtual memory

Hi, Would any one be so kind to explain me : are ulimits defined for each user seperately ? When ? Specialy what is the impact of : max locked memory and virtual memory on performance of applications for a user. Many thanks. PS : this is what I can see in MAN : ulimit ] ... (5 Replies)
Discussion started by: big123456
5 Replies

5. HP-UX

Virtual Memory

Hi! I work with HP-UX and I have to monitorize the use of virtual memory for different processes. (java processes for Tibco Adapter) And if these processes exceed a limit send a message to the syslog. I donīt know how to monitorize this... Should I do a script? or use an aplication, for example... (3 Replies)
Discussion started by: Kurohana
3 Replies

6. Programming

how allocate virtual memory

Hi Folks can any body suggest how to allocate virtual memory any function for that (2 Replies)
Discussion started by: munnu
2 Replies

7. Programming

about virtual memory and memory leak

Hi, First of all I appreciate this group very much for its informative discussions and posts. Here is my question. I have one process whose virtual memory size increases linearly from 6MB to 12MB in 20 minutes. Does that mean my process has memory leaks? In what cases does the... (4 Replies)
Discussion started by: shriashishpatil
4 Replies

8. UNIX for Dummies Questions & Answers

virtual memory

Hi, can anyone explain me what virtual memory is ( for which we use vmstat commande line ) comparing with RAM ? many thanks before. (2 Replies)
Discussion started by: big123456
2 Replies

9. Shell Programming and Scripting

get physical and virtual memory

What command can i use to get the physical and virtual memory of a database? (7 Replies)
Discussion started by: tads98
7 Replies

10. Shell Programming and Scripting

Memory/virtual space

HP UNIX version 10.20 I have been using system variable names in some shell scripts in order to automate execution of some test software. I have recently found that there appears to be a restriction with the 'ls' command when listing specific files (e.g. ls *.c). If I pipe the output into wc, I... (5 Replies)
Discussion started by: degwright
5 Replies
Login or Register to Ask a Question