Hi all,
this is my first post, i need to write a script to zip the files with datewise below are the log files.
-rw------- 1 root sso 85316156 May 24 22:11 core_test_smservaz_104_104_1243217459_8896
-rw------- 1 root sso 90413304 May 25 22:12 core_test_smservaz_104_104_1243303895_20912
-rw------- 1 root sso 86430300 May 26 22:11 core_test_smservaz_104_104_1243390261_3526
Need to zip the previous date only, Current date file should not be zipped.
Please help me writing script..
i will give you a head start , since you are first post.
you can use find with -mtime +1 to find files more than 1 day old. pass it through a while read loop and zip the file. man zip for more info on zip. (or you can use -exec directly)
for the files older than 1 day in the current dir
find . -mtime +1 -print | zip zipfilename -@
thanks for your replies,
when i tried the above comands, while running the script
i m getting the below error message,
/var/tmp/chandu/backup/core_test_smserv.gz
gzip: /var/tmp/chandu/backup/core_test_smserv.gz already has .gz suffix -- unchanged
/var/tmp/chandu/backup/core_test_smservauth.gz
gzip: /var/tmp/chandu/backup/core_test_smservauth.gz already has .gz suffix -- unchanged
/var/tmp/chandu/backup/core_test_smservauth_1234.gz
hlep me in this....
regards,
Chandrasekhar
find . -type f -mtime +1 -exec gzip {} \;
-Devaraj Takhellambam