linux笔记
删除10天以外的数据:
find ./ -type f -mtime +10|xargs rm -rf
查看10以外的数据:
find ./ -type f -mtime +10|xargs ls -l
nginx添加服务:
vi /etc/rc.d/init.d/nginx
脚本:
#!/bin/sh
#chkconfig: 2345 10 90
#name: nginx
#description: Nginx Service Script
#
case $1 in
start)
echo "Starting Nginx..."
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
;;
stop)
echo "Stopping Nginx..."
/usr/bin/killall -s QUIT nginx
;;
restart)
echo "Reloading Nginx..."
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
chmod 777 /etc/rc.d/init.d/nginx
chkconfig --add nginx
chkconfig --level 35 nginx on
Linux tomcat配置:
1,修改catalina.sh
#chkconfig: 35 84 16
#description: tomcat
export JAVA_HOME=/usr/java/jdk1.7.0_25
export JRE_HOME=/usr/java/jdk1.7.0_25/jre
export CATALINA_HOME=/usr/local/tools/apache-tomcat-7.0.41
export CATALINA_BASE=/usr/local/tools/apache-tomcat-7.0.41
Win者改成:
set CATALINA_HOME=/usr/local/tools/apache-tomcat-7.0.41
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1048m -Xmx1048m -XX:PermSize=128M -XX:MaxNewSize=128M -XX:MaxPermSize=256M -XX:+DisableExplicitGC"
或者修改:
/etc/profile
export CATALINA_HOME_82="/data/tools/apache-tomcat-7.0.41_82"
export CATALINA_BASE_82="/data/tools/apache-tomcat-7.0.41_82"
export CATALINA_HOME_83="/data/tools/apache-tomcat-7.0.41_83"
export CATALINA_BASE_83="/data/tools/apache-tomcat-7.0.41_83"
2,设置服务启动
把 catalina.sh copy至:
/etc/rc.d/init.d/tomcat83
chkconfig --add tomcat83
chkconfig --level 35 tomcat83 on
- #!/bin/bash
- ## 间隔1天执行该脚本
- ## Nginx 日志文件所在的目录
- LOGS_PATH=/usr/local/nginx/logs
- ## Nginx 日志文件生成后的目录
- NEWLOGS_PATH=/home/wwwlogs
- ## 获取昨天的 yyyy-MM-dd
- YESTERDAY=$(date -d "yesterday" +%Y%m%d)
- ## 移动文件
- mv ${LOGS_PATH}/access.log ${NEWLOGS_PATH}/access_${YESTERDAY}.log
- ## 向 Nginx 主进程发送 USR1 信号。USR1 信号是重新打开日志文件
- kill -USR1 $(cat /usr/local/nginx/nginx.pid)