How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also?

I found one command which is to create gz file for the older files, but it creates only one gz file for all older file. But I need individual gz file for each log file.

find /tmp/log/ -mtime +180 | xargs tar -czvPf /tmp/older_log_$(date +%F).tar.gz

Thanking you in advance.
Regards,
Mallik

find /tmp/log/ -type f -size +0 ! -name '*.gz' -mtime +180 |
while read f
do
  cp -p "$f" "$f".0 &&
  gzip "$f".0
done

But maybe your OS provides the more robust rotatelog or logadm?

Thanks a lot for your reply.

I put below lines (marked with blue color) in a script file "only_zip.sh" and trying to execute it, but giving the error

find /tmp/mallik3/ -type f -size +0 ! -name '*.gz' -mtime +180 |
while read f
do
  cp -p "$f" "$f".0 &&
  gzip "$f".0
done

Above script gives below error:

: command not found:
only_zip.sh: line 6: syntax error near unexpected token `done'
only_zip.sh: line 6: `done'

____________________
And I put extra commands in the another file "log_script_n.sh
" (marked with blue color) and trying to execute

#Deletes the files older than 365 days
find /tmp/mallik3/ -mtime +2200 -exec rm -f {} \;
#Make the zip/gz/compress the files, if those are older than 6 months
#another way of doing
find /tmp/mallik3/ -type f -size +0 ! -name '*.gz' -mtime +180 |
while read f
do
  cp -p "$f" "$f".0 &&
  gzip "$f".0
done
#Delete the file older than 6 months (which are alredy zipped).
find /tmp/mallik3/ -mtime +180 -exec rm -f {} \;

gives below error:

find: missing argument to `-exec'
: command not foundne 9:
log_script_n.sh: line 17: syntax error: unexpected end of file
-bash-3.2$

Could you please help in this regard.

I guess you used a Windoze text editor that saved the file in Windoze format.

Thanks a lot for your reply.
I got it.

 
files=($(find /tmp/mallik3/ -mtime +"$days"))
 for files in ${files
[*]}
 do
         echo $files
         zip $files-$(date --date="- "$days"days" +%F)_.zip $files
          #       tar cvfz $(files)_$(date --date='-6months' +%F).tar.gz $files
 #       rm $files
 done