How do you empty an out file while the jvm is still running?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How do you empty an out file while the jvm is still running?
# 1  
Old 11-28-2012
How do you empty an out file while the jvm is still running?

How do you empty an out file while the jvm is still running?
# 2  
Old 11-28-2012
This is not a problem unique to java. Any file that's still in use will remain on disk after deletion, until it's actually closed.

The solution is to truncate the file instead of deleting it. Set its size to zero. In the shell this would be : > filename

If the java program doesn't check that the length of the file has changed, though, it may keep appending to the end of it, wherever it is -- filling the space before it with (probably sparse) null characters. If the file was opened for appending, it will probably be okay.

And if you already deleted the file, you may have to close and restart the program to regain control, since the file is now inaccessible from anywhere else.

Last edited by Corona688; 11-28-2012 at 11:38 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to reformat output if input file is empty, but not if file has data in it

The below awk improved bu @MadeInGermany, works great as long as the input file has data in it in the below format: input chrX 25031028 25031925 chrX:25031028-25031925 ARX 631 18 chrX 25031028 25031925 chrX:25031028-25031925 ARX 632 14... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. AIX

JVM Process Name

Hi - In AIX, how do I find the Java Virtual Machine Process Name running on a particular machine? I tried ps -ef | grep java but it does not return a process name. Please help. (4 Replies)
Discussion started by: ocbit
4 Replies

3. UNIX for Dummies Questions & Answers

JVM Memory

Hi all, I am starting a JVM in unix and when I use ps command on the pid of process starting JVM the output is something like this :- java -Xms32M -Xmx64M -Xmx128M I need to know what would be the value of Xmx in this case. And how to check that this value be picked while starting JVM... (3 Replies)
Discussion started by: Raj999
3 Replies

4. Shell Programming and Scripting

Script stops running after assigning empty string for a variable

Hi, This is the first time I see something like this, and I don't why it happens. Please give me some help. I am really appreciate it. Basically I am trying to remove all empty lines of an input.. #!/bin/bash set -e set -x str1=`echo -e "\nhaha" | grep -v ^$` #str2=`echo -e "\n" |... (4 Replies)
Discussion started by: yoyomano
4 Replies

5. Web Development

need help about jvm

hi all i want to install apache and tomcat in unix solaris 10 so i need to konw about heap and jvm memory architecture in jdk version 4 and 5 and 6 i want one help me i searched alot and i can't find something helo me (1 Reply)
Discussion started by: maxim42
1 Replies

6. UNIX for Dummies Questions & Answers

Getting same exit status for empty and non empty file

Hi All, I am checking for a empty input file to do some further action , but I am getting exit status 0 in both the cases , for empty and non empty file both. The value of $? is coming 0 in if part also and else part too. #!/bin/ksh if ]; then echo "data" # exit 0 echo "$?" else... (4 Replies)
Discussion started by: mavesum
4 Replies

7. AIX

AIX JVM -32 or 64?

Friends, Can any one tell me what command should be used to check whether the JVM in AIX is 32 bit or 64 bit? Thanks, Govindh (2 Replies)
Discussion started by: Govindh.v
2 Replies

8. AIX

JVM Setting

What should be the idle JVM setting for the LPAR having 16 GB of memory? Currently the JVM setting is set to -Xms1024M -Xmx10240M (1 Reply)
Discussion started by: aajmani
1 Replies

9. UNIX for Dummies Questions & Answers

Trying to empty file using > but the file size increasing when next append

AIX 5.3 / KSH I have a Java application which creates a log file a.log. I have a KSH script which does the following action cp a.log /directory2/b.log > a.log After this the file size goes to 0 as per "ls -l" Then next time when the application writes into this file, the file size... (4 Replies)
Discussion started by: firdousamir
4 Replies

10. UNIX for Dummies Questions & Answers

Instaling JVM

Hi Everyone I`ve just started with unix can some please help me execute this command via webmin on avirtual server or how do you execute such .bin file this is the error ./j2sdk-1_3_1_15-linux-i586.bin: not found > ls -l total 69124 -rw------- 1 root wheel 8380 May 15 18:01... (2 Replies)
Discussion started by: J.Carlos MC05
2 Replies
Login or Register to Ask a Question