Created
April 18, 2019 13:13
-
-
Save marcostolosa/a1a88801154666258001a4b110bba959 to your computer and use it in GitHub Desktop.
A sample shell script created to clean up cached files from lighttpd web server every 10 days. This script is directly created at /etc/cron.daliy/ directory.
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 | |
CROOT="/tmp/cachelighttpd/" | |
# Clean files every $DAYS | |
DAYS=10 | |
# Web server username and group name | |
LUSER="lighttpd" | |
LGROUP="lighttpd" | |
# Okay, let us start cleaning as per $DAYS | |
/usr/bin/find ${CROOT} -type f -mtime +${DAYS} | xargs -r /bin/rm | |
# Failsafe | |
# if directory deleted by some other script just get it back | |
if [ ! -d $CROOT ] | |
then | |
/bin/mkdir -p $CROOT | |
/bin/chown ${LUSER}:${LGROUP} ${CROOT} | |
fi | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment