查看端口占用
lsof -i:3002
netstat -tunlp | grep 3002
查看idea进程
ps aux | grep intellij
设置pip阿里镜像源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
查看系统版本信息的命令
lsb_release -a
# 使用命令时提示command not found,需要安装yum install redhat-lsb -y
宝塔磁盘自动挂载
Centos系统请使用以下命令:
yum install wget -y && wget -O auto_disk.sh http://download.bt.cn/tools/auto_disk.sh && bash auto_disk.sh
Ubuntu系统请使用以下命令:
wget -O auto_disk.sh http://download.bt.cn/tools/auto_disk.sh && sudo bash auto_disk.sh
Debian系统请使用以下命令:
wget -O auto_disk.sh http://download.bt.cn/tools/auto_disk.sh && bash auto_disk.sh
宝塔安装命令
curl -sSO http://download.bt.cn/install/install_panel.sh && bash install_panel.sh
删除标签为 none 的镜像
docker images|grep none|awk '{print $3 }'|xargs docker rmi
查看容器信息
docker inspect spider
加入网络
docker network connect wits_information_platform_network spider
supervisord 常用命令
# 初始启动Supervisord,启动、管理配置中设置的进程
supervisord
# 停止(启动,重启)某一个进程(xxx)
supervisorctl stop(start, restart) xxx
# 只载入最新的配置文件, 并不重启任何进程
supervisorctl reread
# 载入最新的配置文件,停止原来的所有进程并按新的配置启动管理所有进程
supervisorctl reload
# 根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启
supervisorctl update
查看锁表信息
SELECT A
.datname,
locktype,
virtualtransaction,
transactionid,
nspname,
relname,
MODE,
GRANTED,
CAST ( date_trunc( 'second', query_start ) AS TIMESTAMP ) AS query_start
FROM
pg_locks
LEFT OUTER JOIN pg_class ON ( pg_locks.relation = pg_class.oid )
LEFT OUTER JOIN pg_namespace ON ( pg_namespace.oid = pg_class.relnamespace ),
pg_stat_activity A
WHERE
NOT pg_locks.pid = pg_backend_pid ( )
AND pg_locks.pid = A.pid;
// 查询被锁的pid以及语句, state这列如果显示成 idle in transaction 就表示被锁了
SELECT
pid,
STATE,
usename,
query,
query_start
FROM
pg_stat_activity
WHERE
pid IN ( SELECT pid FROM pg_locks l JOIN pg_class T ON l.relation = T.oid AND T.relkind = 'r' );
// 解锁
// 温柔一点的(只kill掉select)
SELECT pg_cancel_backend(pid)
// 暴力一点的(kill掉 select、update、insert、delete)
SELECT pg_terminate_backend(pid)
postgre重置自增ID
# django-admin-sqlsequencereset
SELECT setval('data_tracking_au_sec_id_seq', (SELECT MAX(id) FROM data_tracking_au_sec)+1);
# data_tracking_au_sec_id_seq:可以再DDL查看到
# data_tracking_au_sec:表名