首页 > 代码库 > Linux常用

Linux常用

使用shell判断系统时区

if [[ ! `grep -a CST-8 /etc/localtime` ]]; then
    rm -rf /etc/localtime
    ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
fi

Nginx日志切割脚本

#!/bin/bash  
logs_path="/alidata/server/log/nginx/"   
mv ${logs_path}access.log ${logs_path}access_$(date -d "yesterday" +"%Y%m%d").log   
kill -USR1 `cat /alidata/server/nginx/logs/nginx.pid`
添加权限后加入crontab中:  
chmod +x /alidata/server/nginx/sbin/split_nginx_log.sh   
crontab -e   
0 1 * * * /alidata/server/nginx/sbin/split_nginx_log.sh


本文出自 “从心开始” 博客,请务必保留此出处http://fuquanjun.blog.51cto.com/5820068/1408289