cento脚本备忘

 

  不是经常用,但又有用的脚本:

  • 批量杀死tomcat进程,grep -v grep去除含有关键字“grep”的进程(排除grep语句本身);awk获取第2列(进程号);xargs把前面命令的输出结果(PID)作为“kill -9”命令的参数,并执行该令
    方法一:ps -ef|grep tomcat | grep -v grep | awk '{printf $2"\n"}'|xargs kill -9
    方法二:ps -ef|grep tomcat | grep -v grep | awk '{if($2>0){print "kill -9 "$2}}' |sh  (据说方法一中如果未查找到进程,kill -9 会传空的参数,会报错)

     

  • 停止oracle数据库:
    #停侦听
    lsnrctl stop
    #停节点 sqlplus /nolog connect /as sysdba shutdown immediate exit
    #集群(需root用户,/oracle/app/11.2.0/grid/product/bin目录下)
    ./crsctl stop crs 关闭整个高可用服务,只能关闭local节点
    ./crsctl stop cluster -all   关闭所有节点的clusterware包括资源。OHAS还在

    如果这样停不下来,参见:https://www.cnblogs.com/linyfeng/p/7496538.html

  • 设置代理:一般是配置/配置文件方式或命令方式
    • linux全局配置:/etc/profile、单个用户配置:~/.bashrc
      export http_proxy="http://user:pwd@proxyip:3128"
      export https_proxy="http://user:pwd@proxyip:3128"
    • yum
      配置方式:/etc/yum.conf
      proxy=http://proxyip:3128
      proxy_username=username
      proxy_password=password
    • rpm
      配置方式:~/.bash_profile
      export http_proxy=http://proxyip:3128/ 
      export ftp_proxy=http://proxyip:3128/ 
    • wget
      配置方式: /etc/wgetrc
      http_proxy = http://proxyip:3128/
      ftp_proxy = http://proxyip:3128/
      命令方式:
    • curl
      配置方式:~/.curlrc
      export http_proxy="http://user:pwd@proxyip:3128"
      export https_proxy="http://user:pwd@proxyip:3128"
      命令方式:
      curl -x "http://user:pwd@proxyip:3128" "http://destination"
  • 通过yum安装nginx:先安装nginx的yum源:rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
  • 让history命令输出时间、pid:echo 'HISTTIMEFORMAT="%F %T "' >> /etc/profile
posted @ 2020-08-22 15:15  badwood  阅读(102)  评论(0编辑  收藏  举报
Badwood's Blog