Computing.Net > Forums > Unix > copying running log files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

copying running log files

Reply to Message Icon

Name: agha
Date: July 22, 2005 at 04:33:33 Pacific
OS: UNIX
CPU/Ram: 512
Comment:

I have some logs files that are runing and never stops. After few days they becomes very huge. I want to move them to other place , and than make there contents to null such that there size becomes 0.
Please help me in this regard.




Sponsored Link
Ads by Google

Response Number 1
Name: Dlonra
Date: July 23, 2005 at 16:58:43 Pacific
Reply:

to accomplish this, the first requirement is that the processes which write into the logfiles either have to be off (terminated), or these processes close the log file after each write (unlikely).

is either of these this your case?

you will have to use cron() to implement this: man cron
and google: cron tutorial


0

Response Number 2
Name: Luke Chi
Date: August 9, 2005 at 17:39:18 Pacific
Reply:

# Save a copy of incoming entries to abc1_catch too
tail -fn 0 abc1 | tee abc1_catch &
# Make a copy of abc1
cp abc1 abc1_part

# empty abc1. So, abc1 file is always available. Almost at the same time stop copying the entries to abc1_catch
> abc1;kill -9 `ps -ef|grep tail|grep -v grep|awk '{print $2}'

# append the abc1_catch and abc1_whole is the file you need to move to another server

cat abc1_part abc1_catch > abc1_whole

Luke Chi


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: copying running log files

Two scripts pipe to a log file www.computing.net/answers/unix/two-scripts-pipe-to-a-log-file/3599.html

where to find email log files www.computing.net/answers/unix/where-to-find-email-log-files/7972.html

scan log file by a search string www.computing.net/answers/unix/scan-log-file-by-a-search-string/8153.html