#!/bin/sh
HOME=xxx
CONFIGFILE=HouseKeeping.config
LOGFILE=HouseKeepingLog.txt
date | tee -a $LOGFILE | cat
echo "**********************Script start**********************" | tee -a $LOGFILE | cat
cd $HOME
count=0
sum=0
while read conLine
do
count=`expr $count + 1`
path=`echo $conLine | awk '{print $1}'`
type=`echo $conLine | awk '{print $2}'`
time=`echo $conLine | awk '{print $3}'`
echo "No."$count" Directory: "$path | tee -a $LOGFILE | cat
if [ -e $path ]; then
if [ $type -eq 1 ]; then
find $path ! -path $path -type d -mtime +$time | while read LINE
do
sum=`expr $sum + 1`
echo "Remove Directory "$LINE | tee -a $LOGFILE | cat
rm -rf "$LINE"
done
elif [ $type -eq 2 ]; then
find $path -type f -mtime +$time | while read LINE
do
sum=`expr $sum + 1`
echo "Remove File "$LINE | tee -a $LOGFILE | cat
rm -rf "$LINE"
done
else
echo "Illegal Parameter." | tee -a $LOGFILE | cat
fi
else
echo "The specified directory doesn't exist." | tee -a $LOGFILE | cat
fi
done < $CONFIGFILE
echo $count" directory have been processed and "$sum" File/Folder have been deleted." | tee -a $LOGFILE | cat
echo "**********************Script end**********************" | tee -a $LOGFILE | cat
date | tee -a $LOGFILE | cat
分享到:
相关推荐
shell script学习中的笔记
一直很喜欢写unix shell script, 因为写那么一点点东西可以有那么多效果,投入小,产出大,爽啊. 在写IBM AIX K Shell script时,感觉不那么友好,主要是有一些格式细节要求比较严格,不太习惯,后来写惯了也就好了,下面的...
shfmt_v3.1.2_windows_amd64.exe shfmt_v3.1.2_windows_386.exe 解决idea would you like to install a shell script formatter?的问题
身為 UNIX 系統管理者除了要熟悉 UNIX 指令外,我們最好學會幾種 scripts 語言,例如 shell script 或 perl。學會 script 語言後,我們就可以將日常的系統管理工作寫成一支執行檔,如此一來,在管理系統時就可以更加...
shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法
Linux shell Script
this is a shell script learning
shell script 语言教程 非常好的入门级材料,适合速成。
shellscript shellscript
Shell脚本编程(scripting)的技巧永远不会过时:它们可以让UNIX充分发挥其真实的潜能。对UNIX的用户与系统管理者而言,编写Shell脚本是必须的工作,它可以让你快速地控制与定制任何UNIX系统的强大功能。有了Shell...
C Shell 教程 英文版 2007年5月出版
shell_script.tar.gz
Jenkins构建Execute shell script on remote host using ssh命令;JenkinsSSH执行命令;
微软操作系统 windows脚本编程,适合初学者。
shell script 的语法、判断式、循环、括号的区别、跟踪与调试。
shell-script-template, 简单( 希望有用) shell script 模板 通用模板 。描述数百万开发人员编写 shell 脚本来解决各种类型的任务。 我使用 shell 脚本简化部署。生命周期管理。安装或者仅仅作为一种粘合剂语言。 ...
shell脚本参考和python脚本参考