Skip to content

Instantly share code, notes, and snippets.

@zeraf29
Created November 14, 2017 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeraf29/06ce7f7b39331d35fc75ce3bdfb445cf to your computer and use it in GitHub Desktop.
Save zeraf29/06ce7f7b39331d35fc75ce3bdfb445cf to your computer and use it in GitHub Desktop.
The shell program for deleting log with crontab on Linux
#!/bin/bash
#2017-10-19 jinhyup Kim
#Move to directory which will delete logs
cd /data/logs/
#find . : Find files at current and below folders
#-name ' ' : About files named ' ', 'Server_*.log' = likely 'Server_201711.log', 'Server_something.log', and e.t.c
# -mtime +30 : Files made before 30 days
# -exec rm {} : Excute rm(remove) command about upper files
find . -name 'Server_*.log' -mtime +30 -exec rm {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment