Copy open active log

Hi,
I try to copy the nohup.out to new file using cp command on solaris 10
However, the new file is very large size compare to nohup.out

The file is in English format text.

Any solution for copying active/open log file without problem with the size.

ex:

/dir > du -sh nohup.out
636K   nohup.out
/dir > file nohup.out
nohup.out:      English text
/dir > cp nohup.out nohup1.out
/dir > du -sh nohup*
636K   nohup.out
1.7G   nohup1.out

Thanks,
Xitrum

It must be a sparse file, to blow up like that when copied. Compare ls -lh nohup.out with du -hs nohup.out , if they differ significantly, nohup.out is sparse.

As for why nohup.out is sparse, have you been truncating the file while its still live? This will cause large amounts of empty space at the beginning of the file since the process will continue writing at the "end". They won't be stored on disk, just assumed to be there, until you copy it.

That problem will need to be taken care of before you can copy the file.

sparse file, mayhap? Does your cp have the --sparse=WHEN option?
Are the contents of the two files identical?

Thank you very much for a quick respond.
This is new to me. They are different when using ls -lh and du -sh.

/dir > ls -lh nohup.out
-rw------- 1 a b 1.7G Mar 10 15:02 nohup.out
/dir > du -sh nohup.out
3.9M nohup.out
/dir >

How can I solve this problem ?
thank you vey much.

Whatever is writing these nohup.out files will need modification, to prevent it writing sparse files. What you're doing right now isn't working, it's generating these weird sparse files instead of starting over at position zero.

What's writing these logfiles? Can you show us the code? You may be able to convince it to move its own logfiles on command.

it is an out put of the weblogic.

nohup ./startweblogic.sh &

<Mar 10, 2017 01:24:01>  WARN [DefaultQuartzScheduler_Worker-1] (?:?) - no chg in JobTriggerTime; set to null
<Mar 10, 2017 01:24:01>  WARN [DefaultQuartzScheduler_Worker-1] (?:?) - JobSchedulerDAO.hasJobTriggerTimeChanged() called ...
<Mar 10, 2017 01:24:01>  WARN [DefaultQuartzScheduler_Worker-1] (?:?) - getScheduledJobs sql == select job_trigger_time from BATCH_JOB_SCHEDULE where job_id = 30
<Mar 10, 2017 01:24:01>  WARN [DefaultQuartzScheduler_Worker-1] (?:?) - newJobTriggerTime == 07:00:00
jobID == 30
old time == 07:00:00
new time == 07:00:00
<Mar 10, 2017 01:24:01>  WARN [DefaultQuartzScheduler_Worker-1] (?:?) - no chg in JobTriggerTime; set to null
<Mar 10, 2017 01:24:01>  WARN [DefaultQuartzScheduler_Worker-3] (?:?) - checkJobStartFlag called ...
<Mar 10, 2017 01:24:01>  WARN [DefaultQuartzScheduler_Worker-3] (?:?) - checkJobStartFlag query == select job_start_flag from batch_job_schedule where job_id = 24
<Mar 10, 2017 01:24:01>  WARN [DefaultQuartzScheduler_Worker-10] (?:?) - checkJobStartFlag called ...
<Mar 10, 2017 01:24:01>  WARN [DefaultQuartzScheduler_Worker-10] (?:?) - checkJobStartFlag query == select job_start_flag from batch_job_schedule where job_id = 31
####### Unlocking the items if there are any ######
####### End of Unlocking the items if there are any ######
<Mar 10, 2017 01:24:04>  WARN [DefaultQuartzScheduler_Worker-4] (?:?) - JobInvoker.runPostLoadFromColl(): POSTLOAD_FROM_COLLECTION end .. 
PollerJob is executing. Time:3/10/17 1:26 PM
PollerJob triggerTimesMap:{19=15:00:00, 21=05:45:00, 20=15:00:00, 25=16:00:00, 26=05:45:00, 29=06:00:00, 30=07:00:00}
<Mar 10, 2017 01:26:01>  WARN [DefaultQuartzScheduler_Worker-6] (?:?) - JobSchedulerDAO.hasJobTriggerTimeChanged() called ...
<Mar 10, 2017 01:26:01>  WARN [DefaultQuartzScheduler_Worker-6] (?:?) - getScheduledJobs sql == select job_trigger_time from BATCH_JOB_SCHEDULE where job_id = 19
<Mar 10, 2017 01:26:01>  WARN [DefaultQuartzScheduler_Worker-6] (?:?) - newJobTriggerTime == 15:00:00
jobID == 19
old time == 15:00:00
new time == 15:00:00
<Mar 10, 2017 01:26:01>  WARN [DefaultQuartzScheduler_Worker-6] (?:?) - no chg in JobTriggerTime; set to null
<Mar 10, 2017 01:26:01>  WARN [DefaultQuartzScheduler_Worker-6] (?:?) - JobSchedulerDAO.hasJobTriggerTimeChanged() called ...
<Mar 10, 2017 01:26:01>  WARN [DefaultQuartzScheduler_Worker-6] (?:?) - getScheduledJobs sql == select job_trigger_time from BATCH_JOB_SCHEDULE where job_id = 21
<Mar 10, 2017 01:26:01>  WARN [DefaultQuartzScheduler_Worker-6] (?:?) - newJobTriggerTime == 05:45:00
jobID == 21
old time == 05:45:00
new time == 05:45:00
<Mar 10, 2017 01:26:01>  WARN [DefaultQuartzScheduler_Worker-6] (?:?) - no chg in JobTriggerTime; set to null

Use code tags for code, please. [ code ] stuff [ /code ] without the extra spaces in the tags.

Oracle has its own logger system you should use, not files logged ad-hoc like this. They will rotate themselves.