Hi,
Thanks to you all for showing interest in helping me out !
Well. I will again try to define the problem and the resolution I have reached so far !
Currently I have a log file at the location /home/usr/workarea/GeneratedLogs.log in which the logs get appended every second :-
Logs example :-
(Apr 15, 2011 12:22:00 PM), Setup, com.installshield.product.service.registry.PureJavaRegistryServiceImpl, dbg.registry
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
last modified date = (Wed Apr 13 11:05:22 CEST 2011) -----
(Apr 16, 2011 1:47:39 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
ast modified date = (Wed Apr 20 13:49:11 CEST 2011) -----
(Apr 16, 2011 1:49:15 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 16, 2011 3:14:25 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
(Apr 17, 2011 7:40:10 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
(Apr 17, 2011 7:40:10 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
(Apr 21, 2011 11:13:33 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
(Apr 21, 2011 11:13:33 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
(Apr 21, 2011 11:13:33 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
(Apr 21, 2011 11:13:33 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
(Apr 21, 2011 11:13:33 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
(Apr 22, 2011 6:28:15 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
(Apr 22, 2011 6:29:15 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
(Apr 22, 2011 6:29:15 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
(Apr 22, 2011 6:19:15 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
Now I want to cut the contents from this file based on date i.e. I am expecting the below log files in a new file at the location /home/usr/workarea/LogCopy.log
Expected Log File e.g LogCopy.log_11_04_15_12_22:-
(Apr 15, 2011 12:22:00 PM), Setup, com.installshield.product.service.registry.PureJavaRegistryServiceImpl, dbg.registry
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 15, 2011 12:22:02 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
LogCopy.log_11_04_16_1_47 :-
(Apr 16, 2011 1:47:39 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
ast modified date = (Wed Apr 20 13:49:11 CEST 2011) -----
(Apr 16, 2011 1:49:15 PM), Setup, com.tibco.installer.util.TIBCOInstaller, dbg.Debug
(Apr 16, 2011 3:14:25 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
LogCopy.log_11_04_17_7_40 :-
(Apr 17, 2011 7:40:10 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
(Apr 17, 2011 7:40:10 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
LogCopy.log_11_04_21_11_13 :-
(Apr 21, 2011 11:13:33 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
(Apr 21, 2011 11:13:33 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
(Apr 21, 2011 11:13:33 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
(Apr 21, 2011 11:13:33 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
(Apr 21, 2011 11:13:33 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
LogCopy.log_11_04_22_6_28 :-
(Apr 22, 2011 6:28:15 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
(Apr 22, 2011 6:29:15 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
(Apr 22, 2011 6:29:15 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, target platform: name="AIX" version="5.3" arch="ppc"
(Apr 22, 2011 6:19:15 PM), Setup, com.installshield.wizardx.conditions.PlatformWizardBeanCondition, dbg.platform, condition platform: name="Windows .*" version="." arch
="."
Problem faced :-
I used the following command :-
find /home/usr/workarea/GeneratedLogs.log -mtime +0 -exec cp{} /home/usr/workarea/LogCopy.log_$(date +%y_%m_%d_%H_%M) \;
This command was able to copy the contents from the parent log file into the new child file. But, the contents in the parent file were not deleted !
So, I tried with the following cut command :-
find /home/usr/workarea/GeneratedLogs.log -exec cut -c- /home/usr/workarea/LogCopy.log_$(date +%y_%m_%d_%H_%M) \;
This command failed to perform its operation !! No idea why !!!!!!! LLL
So, I tried the other way round.
(1.) I used the following command to first copy the contents from parent file to the new child file using :-
find /home/usr/workarea/GeneratedLogs.log -mtime +0 -exec cp{} /home/usr/workarea/LogCopy.log_$(date +%y_%m_%d_%H_%M) \;
(2.) Later I used the following command to empty the parent file at the location : /home/usr/workarea/GeneratedLogs.log
By using :-
cat /dev/null > GeneratedLogs.log
Requirement :-
Is it not possible to club all this in one single command ! i.e. from the parent log file all the logs should get cut paste into new child file appended with the date.
Once the new child files are created then I need to delete those files which are older than 7 days ! Now how will I achieve that ????
I hope now I have made problem clear. Please let me know if more inputs are required in arriving at a solution !
Thanks.