服务器相关

mac 终端链接到 远程服务器 ssh root@ip address

查看 java 端口占用情况 ps -ef|grep java

关闭占用端口 kill -9 端口

ubuntu 修改config   vim 

安装程序 apt-get 名字     启动mysql  service mysql start、restart、stop

set global wait_timeout=10 设置sleep 时间, 减小数据库链接得占用 ; 查询链接数 show processlist

 

--shell脚本

yesterday=$(date -d '-2day' +%Y-%m-%d)" 23:59:59"

tomorrow=$(date +%Y-%m-%d)" 00:00:00"

 

 

数据库my.cnf 的 mysqldump 添加数据库密码和用户

mysqldump -u root dbname \

tabel -w "createtime > '$yesterday' andcreatetime < '$tomorrow'" \

-t --compact > "name_"$(date +%Y%m%d).sql

导出得文件目录需要读写权限,否则不能导出文件

 

java 获取文件路径 调用shell 脚本

String path = Class.class.getClassLoader().getResource("tanyu_backup.sh").toURI().getPath();

String strCmd = "sh " + path;// 执行shell命令

Process process = Runtime.getRuntime().exec(strCmd);// 通过执行cmd命令调用protoc.exe程序

BufferedReader strCon = new BufferedReader(new InputStreamReader(process.getInputStream()));

String line;

while ((line = strCon.readLine()) != null) {

if (line.equals("#") || line.equals("Not connected.")) {

return line;

}

}

自动上传服务器  需要开通文件夹权限

ftp -n<<!
open ipaddress
user username password
prompt
mkdir $(date +%Y%m) //创建文件夹
binary
hash
cd $(date +%Y%m)
mput "cjhwy_"$(date +%Y%m%d).zip
close
bye
!

 

posted on 2017-03-17 11:39  minwei  阅读(108)  评论(0编辑  收藏  举报