专注各种脚本编程
Baidu
加入收藏夹
本站内容有下面分类知识,欢迎您的到来^_^
shell相关:指令篇 基础篇 脚本欣赏 编程实例 shell问问 shell视频教程 技巧篇 水平测试 E文资料 vi编辑器 高级Bash脚本编程指南
其他:mysql perl c语言 oracle
当前位置:| 主页>shell脚本欣赏>

清除Lighttpd web服务器缓存的shell脚本

百度收藏 QQ搜藏

原文:http://bash.cyberciti.biz/file-management/cleaning-webserver-cache-script/

    这个shell脚本实现清除Lighttpd web服务器缓存。同时你还要把脚本添加到cron里按计划运行,安装脚本存放到/etc/cron.daily 目录下。

以下是该shell脚本的源代码:

#!/bin/bash
# Shell script to clean web server cache stored at /var/www/cache/ directory.
# -------------------------------------------------------------------------
# Copyright (c) 2007 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
 
# Cache dir path
CROOT="/var/www/cachelighttpd/"
 
#Deleting files older than 10 days
DAYS=10
 
# Lighttpd user and group
LUSER="lighttpd"
LGROUP="lighttpd"
 
# start cleaning
find ${CROOT} -type f -mtime +${DAYS} | xargs -r /bin/rm
 
# if directory missing just recreate it
if [ ! -d $CROOT ]
then
	mkdir -p $CROOT
	chown ${LUSER}:${LGROUP} ${CROOT}
fi
上一篇:Redhat Linux下virtuozzo VPS基于iptables防火墙的shell脚本 下一篇:shell脚本 实现计算英文文章里诸如'A/An/The'个数

power by soyo123 2007-2008