-
-
Save zeraf29/06ce7f7b39331d35fc75ce3bdfb445cf to your computer and use it in GitHub Desktop.
The shell program for deleting log with crontab on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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