script with dates to gzip and remove

Good morning all!

I am new to programming and trying to learn; please be patient.

I am wanting to write a script that takes the current date and gzip 5 days or older, then remove 10 days or older.

This is the directory I want to work in; this is what it looks like

root@bigben:/var/adm/ra: ll
total 84288
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra18
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra19
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra20
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra21
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra22
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra23
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra24
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra25
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra26
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra27
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra28
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra29
-rw-r--r--   1 root       sys        3317184 Aug 31 00:11 ra30
-rw-r--r--   1 root       sys          23036 Aug 31 00:11 ra31

This is what I have:

#Go to specific location
cd /var/adm/ra
#Remove ra logs older than 10 days
find $log_dir -mtime +10 -exec rm -f {} \; 1> /dev/null 2>&1
#Gzipping ra logs older than 5 days
find $log_dir -mtime +5 -exec gzip -f {} \; 1> /dev/null 2>&1

I think my mistake is $log_dir?

Thanks Bigben

add this line before find command:

log_dir=/var/adm/ra

rdcwayx-

thanks! I thought it was the variable.

Does the rest of the script look like it will do what I am trying to get it to?

Ben