Rename log file according to log file age

Hi Experts,

i am new in shell programming. i am having some problem of checking the log file age and rename it.

for example:
when i run the shell script, the script will check how old is the log file, if the log is already 10 days old(variable). then the log file will rename.

hope to hear from you guys soon :slight_smile:

Thanks alot,
ewawong

if you have the stat command, this is how you can get the time of last modification of a file:

stat -c '%y' test.pl
stat -c '%Y' test.pl

you can compare this time with current time to determine if the file is 10 days old

from the stat manual:

       %X     Time of last access as seconds since Epoch

       %x     Time of last access

       %Y     Time of last modification as seconds since Epoch

       %y     Time of last modification

       %Z     Time of last change as seconds since Epoch

       %z     Time of last change

hi Yogesh Sawant, thank you very much for your reply.

when i run the stat command, the console shows me a message "command not found"

i have refer many forums, most of the ppl said that we cant get the created date of a file in unix system, is that true?

if we cant get the file's created date, which means we are not able to check how old is the file right?

ewawong, please read this