-d filename 如果 filename为目录,则为真
-f filename 如果 filename为常规文件,则为真
目录:
path="/home"
#if [ ! -d ${path} ];then
if [ -d ${path} ];then
echo dir ${path} exist!
else
echo dir ${path} not exist!
fi
文件:
file="/home/log.txt"
if [ -f ${file} ];then
echo file ${file} exist!
else
echo file ${file} not exist!
fi
Nginx日志切割
#!/bin/bash
#auto mv nginx log shell
#by author test
S_LOG=/usr/local/nginx/logs/access.log
D_LOG=/data/backup/`date +%Y%m%d`
echo -e "\033[32mPlease wait start cut shell scripts...\033[1m"
sleep 2
if [ ! -d $D_LOG ];then
mkdir -p $D_LOG
fi
mv $S_LOG $D_LOG
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
echo "-------------------------------------------"
echo "The Nginx log Cutting Successfully!"
echo "You can access backup nginx log $D_LOG/access.log files."
此博主较懒不取名
原创文章 297获赞 332访问量 40万+
关注
他的留言板
展开阅读全文
作者:此博主较懒不取名