常用脚本
linux后台跑jar包
1 | nohup java -jar xxx.jar > /dev/null 2>&1 & |
定时重启jar
restart.sh
- 不指定日志输出 使用log组件输出日志
1 |
|
- 指定日志输出
1 |
|
1 | 0 3 * * * restart.sh |
linux后台跑py
1 | nohup python main.py > /dev/null 2>&1 & |
fetch_data.sh
1 | ls_date=`date +%Y%m%d` |
1 | crontab -e |
1 | 0 1 * * * fetch_data.sh |
windows后台跑jar
start.bat
1 | @echo off |
stop.bat
1 | @echo off |
windows powerShell发http请求
1 | curl -Uri 'http://localhost:8080/homePage/upload' -Method 'GET' |
定时清理日志
编辑定时任务
1 | crontab -e |
添加定时任务
1 | 0 0 * * * cat /dev/null > xxx.log |
删除一个月前的日志文件
1 | rm -f `find / -name "*.log" -mtime +30` |
导入jar包到本地maven仓库
1 | mvn install:install-file -Dfile=xxx.jar -DgroupId=com.xxx -DartifactId=mqsdk -Dversion=1.0 -Dpackaging=jar |
windows查看端口占用
1 | netstat -ano | find 端口号 |
杀掉进程
1 | taskkill /f /t /im 进程id |
jar包解压
1 | jar -xvf xxx.jar |
Mysql查看表名的所有字段
1 | SELECT column_name FROM information_schema.columns WHERE table_schema='dbNamw' AND table_name='tableName'; |
Mysql查看列的属性
1 | describe table_name column_name; |
Mysql修改列属性
1 | alter table table_name modify column column_name varchar(255); |
Mysql添加列
1 | alter table table_name add column column_name varchar(255); |
Mysql重命名表
1 | ALTER TABLE table_name_old RENAME table_name_new; |
sqlplus连接oracle
1 | sqlplus64 username/password@ip:port/orcl |
orcle查询最近7天
1 | admission_date between to_char(sysdate-7,'yyyy-mm-dd hh24:mi:ss') and to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') |
查找文件路径
1 | find / -name xxx.jar |
根据进程号查看文件路径
1 | ll /proc/PID |
常用方法
时间段切分方法
1 | public class DateRange { |
1 |
|
<>转换成<>
1 | String unescapeStr = "<name>zhangsan</name>"; |
正则去除<![CDATA[]]>
1 | private static final String regex = "<!\\[CDATA\\[(.*?)\\]\\]>"; |
数据加密与解密
DES对称加密算法
工具类 DESUtils
1 | /** |
调用
1 | String mobileNo = "15027075282" |
多线程数据造测试数据
1 | static class BaseDao { |
List对象指定字段去重
1 | List<User> userList = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(User::getId))),ArrayList::new)); |
List分批
1 | List<List<User>> users = Lists.partition(list,1000); |