目录:
linux下mysql备份脚本
simple tomcat sh
tomcat 6 下开启远程调试
java启动命令
查看tcpdump
linux下mysql备份脚本
#!/bin/bash echo $(date +"%Y-%m-%d %H:%M:%S") backup begin /usr/local/mysql/bin/mysqldump -u root -pmysqladmin --all-databases | gzip -9 > "/data/backup/$(date +"%Y%m%d").sql.gz" echo $(date +"%Y-%m-%d %H:%M:%S") backup end
0.simple tomcat sh:
ps -ef | awk '/tomcat/{print "kill " $2}' | sh
语法:awk '/正则表达式/{print }'
ps -ef | grep java | awk '{print "kill "$2}' | sh
1.这个是修改后的文件,比起之前那个简单了一点,不用生成中间文件。
excu=`ps -ef | grep tomcat | awk '{print $2}'` kill $excu; #start the tomcat server if [ $1 ]; then sh pageapi/tomcat/bin/startup.sh fi
2.添加usage和命令选择的
ACTION=$1 usage() { echo "Usage arg : stop | start | restart"; } stop() { excu=`ps -ef | grep tomcat | awk '{print $2}'` kill $excu; } start() { sh pageapi/tomcat/bin/startup.sh } case "$ACTION" in stop) stop ;; start) start ;; restart) stop start ;; *) usage ;; esac
3.最初的文件,生成中间文件
每次都ps -ef | grep tomcat太累啦~~~~
1.tomcatutil.sh脚本:执行后删除tomcat进程
#delete tomcat process ps -ef | grep tomcat | awk '{print "kill "$2}' > kill2.sh chmod +x kill2.sh sh kill2.sh #if the arg is not null ;start the tomcat server if [ $1 ]; then sh pageapi/tomcat/bin/startup.sh fi
2.如果希望重启,随便给一个参数,就重启啦:
tomcatutil.sh start
-------------------------------------------------------
-------------------------------------------------------
-------------------------------------------------------
-------------------------------------------------------
tomcatutil.sh脚本:执行后删除tomcat进程
JAVA_HOME=/usr/local/jdk1.6 if [ "$1" = "start" ] ; then rm -Rf ../work/Catalina JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -Xms256m -Xmx512m -XX:PermSize=64m -XX:M axPermSize=256m -XX:+PrintGCDetails -Xloggc:../logs/gc$$.log -XX:+HeapDumpOnOutOfMemoryError " fi
set JPDA_ADDRESS=8000 set JPDA_TRANSPORT=dt_socket call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
#!/bin/bash JAVA_HOME=/usr/local/jdk1.6 JAVA_OPTS="-Xms64m -Xmx128m" CLASSPATH=${CLASSPATH}:"/usr/local/loganalyse/classes":`echo /usr/local/loganalyse/lib/*.jar | sed "s/ /:/g"` echo $(date +"%Y-%m-%d %H:%M:%S")" start LogReader" if [ -z "${JAVA_HOME}" ] ; then echo "JAVA_HOME" echo "Please set JAVA_HOME" exit 1 fi if [ ! -x "${JAVA_HOME}/bin/java" ] ; then echo "JAVA_HOME Error" echo "Can not find Java VM" exit 1 fi echo "Using JAVA_HOME ${JAVA_HOME}" echo "Using CLASSPATH ${CLASSPATH}" "${JAVA_HOME}/bin/java" ${JAVA_OPTS} -cp ${CLASSPATH} com.tenpay.open.loganalyse.reader.LogReader echo $(date +"%Y-%m-%d %H:%M:%S")" end LogReader"
#!/usr/bin/expect -- if { [llength $argv] != 5 } { puts "Usage: $argv0 srcFile dstFile IP user passwd" exit 1 } set timeout 3000 #/usr b/postfix/spawn ssh -l[lindex $argv 1] -p36000 [lindex $argv 0] -q "[lindex $argv 3]" spawn rsync -azuv --progress -e "/usr/local/bin/ssh -q -p36000" [lindex $argv 3]@[lindex $argv 2]:[lindex $argv 0] [lindex $argv 1] expect { "*(yes )*" {send "yes\n"; exp_continue;} "*password*" {send "[lindex $argv 4]\n"; exp_continue;} timeout { exec kill -9 [exp_pid]; close; } }
#!/usr/bin/expect -- if { [llength $argv] != 5 } { puts "Usage: $argv0 srcFile dstFile IP user passwd" exit 1 } set timeout 3000 #/usr/shdb/postfix/spawn ssh -l[lindex $argv 1] -p36000 [lindex $argv 0] -q "[lindex $argv 3]" spawn rsync -azuv --progress -e "/usr/local/bin/ssh -q -p36000" [lindex $argv 3]@[lindex $argv 2]:[lindex $argv 0] [lindex $argv 1] expect { "*(yes/no)*" {send "yes\n"; exp_continue;} "*password*" {send "[lindex $argv 4]\n"; exp_continue;} timeout { exec kill -9 [exp_pid]; close; } }
#open api log analyse 40 * * * * /usr/local/loganalyse/loganalyse.sh >> /usr/local/loganalyse/result.log 2>&1 #download 145 api 20 * * * * /data/loganalyse/filedownload.sh >> /data/loganalyse/result.log 2>&1
tcpdump -i any -X -s 2000 -n port 25550
find [directory_name] -type f -print0 | xargs -0 md5sum > md5_result.txt