linux - Deleting files that are older than one day -


this question has answer here:

i have server creates several log files in log directory. due logging mechanism eats lot of disk space on server. want write script deletes files older 1 day , keep latest ones.

i able list directories in sorted form using ls -trl command. not able understand how remove these files. please help.

you can use following command:

/usr/bin/find <your log directory> -mtime +1 | xargs rm -f 

mtime - provides file modification time.

+1 - indicates greater 1 day.