?
Solved

clean up file content

Posted on 2003-03-25
8
Medium Priority
?
242 Views
Last Modified: 2013-12-27
Hi all

I have prepared a shell script such that:
    apple.sh > apple.log

The log file will grow unless the apple.sh is stopped and delete the apple.log.
During runtime, I try to run "cat /dev/null > apple.log" to the file so that the file resume to 0 byte. But the disk space will still occupy the space unless the apple.sh is stopped.

Is there any solution to delete the cleanup the file without stopping the apple.sh ?

Thanks
0
Comment
Question by:glogin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 2

Expert Comment

by:soupdragon
ID: 8201644
If you have written apple.sh yourself you might try to utilise a signal within your script.

for instance near the start of the apple.sh script

trap '> apple.log' INT

then from outside your program kill -INT apple.sh to clear the logfile.

Can't say I've ever tried this myself ;)

SD
0
 
LVL 4

Expert Comment

by:Otetelisanu
ID: 8201769
Test with:
apple.sh >> apple.log


0
 

Author Comment

by:glogin
ID: 8201834
sorry for my misleading question.

the question should be: Is there any solution to cleanup the apple.log without stopping/shutting down the apple.sh?
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 4

Expert Comment

by:Otetelisanu
ID: 8202469
Test with:
apple.sh >> apple.log
and

echo "" >apple.log
0
 
LVL 4

Expert Comment

by:Otetelisanu
ID: 8202485
with
echo "" >apple.log
the file is 1 Byte big
and
the program apple.sh write on the apple.log
0
 
LVL 38

Accepted Solution

by:
yuzh earned 200 total points
ID: 8207238
Here's your problem:

the command line:

apple.sh > apple.log
open the apple.log file, inside the "apple.sh" script, the statement:
cat /dev/null > apple.log

try to write to an OPEN file !!!

Here's the simple answer:

keep "cat /dev/null > apple.log" in the script, run the script in commandline:
apple.sh

as soon as it run "cat /dev/null > apple.log" the log file should be empty.






0
 

Author Comment

by:glogin
ID: 8208345
1. at the beginnng, apple.log = 100MB
2. after running "cat /dev/null > apple.log", the file size is resumed to 0 byte

Question:
will 100MB disk space still be occupied by apple.log if apple.sh does not stop? (as the instance of apple.sh does not stop)
0
 
LVL 38

Expert Comment

by:yuzh
ID: 8208655
When the file size down to 0 byte, the disk space should free up, and it should have nothing to do with the statments after :
cat /dev/null > apple.log



0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question