查看端口占用

  1. lsof -i:3002
  1. netstat -tunlp | grep 3002

查看idea进程

  1. ps aux | grep intellij

设置pip阿里镜像源

  1. pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

查看系统版本信息的命令

  1. lsb_release -a
  2. # 使用命令时提示command not found,需要安装yum install redhat-lsb -y

宝塔磁盘自动挂载

Centos系统请使用以下命令:

  1. yum install wget -y && wget -O auto_disk.sh http://download.bt.cn/tools/auto_disk.sh && bash auto_disk.sh

Ubuntu系统请使用以下命令:

  1. wget -O auto_disk.sh http://download.bt.cn/tools/auto_disk.sh && sudo bash auto_disk.sh

Debian系统请使用以下命令:

  1. wget -O auto_disk.sh http://download.bt.cn/tools/auto_disk.sh && bash auto_disk.sh

宝塔安装命令

  1. curl -sSO http://download.bt.cn/install/install_panel.sh && bash install_panel.sh

删除标签为 none 的镜像

  1. docker images|grep none|awk '{print $3 }'|xargs docker rmi

查看容器信息

  1. docker inspect spider

加入网络

  1. docker network connect wits_information_platform_network spider

supervisord 常用命令

  1. # 初始启动Supervisord,启动、管理配置中设置的进程
  2. supervisord
  3. # 停止(启动,重启)某一个进程(xxx)
  4. supervisorctl stop(start, restart) xxx
  5. # 只载入最新的配置文件, 并不重启任何进程
  6. supervisorctl reread
  7. # 载入最新的配置文件,停止原来的所有进程并按新的配置启动管理所有进程
  8. supervisorctl reload
  9. # 根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启
  10. supervisorctl update

查看锁表信息

  1. SELECT A
  2. .datname,
  3. locktype,
  4. virtualtransaction,
  5. transactionid,
  6. nspname,
  7. relname,
  8. MODE,
  9. GRANTED,
  10. CAST ( date_trunc( 'second', query_start ) AS TIMESTAMP ) AS query_start
  11. FROM
  12. pg_locks
  13. LEFT OUTER JOIN pg_class ON ( pg_locks.relation = pg_class.oid )
  14. LEFT OUTER JOIN pg_namespace ON ( pg_namespace.oid = pg_class.relnamespace ),
  15. pg_stat_activity A
  16. WHERE
  17. NOT pg_locks.pid = pg_backend_pid ( )
  18. AND pg_locks.pid = A.pid;
  1. // 查询被锁的pid以及语句, state这列如果显示成 idle in transaction 就表示被锁了
  2. SELECT
  3. pid,
  4. STATE,
  5. usename,
  6. query,
  7. query_start
  8. FROM
  9. pg_stat_activity
  10. WHERE
  11. pid IN ( SELECT pid FROM pg_locks l JOIN pg_class T ON l.relation = T.oid AND T.relkind = 'r' );
  12. // 解锁
  13. // 温柔一点的(只kill掉select)
  14. SELECT pg_cancel_backend(pid)
  15. // 暴力一点的(kill掉 select、update、insert、delete)
  16. SELECT pg_terminate_backend(pid)

postgre重置自增ID

  1. # django-admin-sqlsequencereset
  2. SELECT setval('data_tracking_au_sec_id_seq', (SELECT MAX(id) FROM data_tracking_au_sec)+1);
  3. # data_tracking_au_sec_id_seq:可以再DDL查看到
  4. # data_tracking_au_sec:表名