shell 常用命令实例

一、项目应用

需要密码的

#!/usr/bin/expect

set timeout 3

spawn mysql.server start
echo "mysql 服务启动成功!"

spawn sh /Users/conan/Documents/tools/apache-tomcat/bin/shutdown.sh
spawn sh /Users/conan/Documents/tools/apache-tomcat/bin/startup.sh
echo "jenkins 服务启动成功!"


spawn sudo uwsgi --ini /Users/conan/vir_env/AutoTest/uwsgi.ini
expect "*password:"
send "conan\r"
interact


spawn sudo nginx -c /Users/conan/vir_env/AutoTest/nginx.conf
expect "*password:"
send "conan\r"
interact

运行时,不要加sh xx.sh,直接运行xx.sh(详情请见:https://blog.csdn.net/weixin_34364071/article/details/92454604)

 

不需要密码

start.sh

#!/bin/bash

#启动 FasterWeb
echo -e "启动 FasterWeb"
cd /home/conan/conan-ta/FasterWeb/
nohup npm run build >> /home/shared/log/npm.log 2>&1 &


# 启动 FasterRunner
echo -e "启动 FasterRunner"
cd /home/conan/conan-ta/FasterRunner/
nohup python3 manage.py runserver 0.0.0.0:9000 >> /home/shared/log/django.log 2>&1 &


# 使用默认的celery.py启动
echo -e "启动celery beat"
cd /home/conan/conan-ta/FasterRunner/
nohup python3 manage.py celery beat -l info >> /Users/zd/Documents/FasterRunner/logs/beat.log 2>&1 &


# 使用默认的celery.py启动
echo -e "启动 celery work"
cd /home/conan/conan-ta/FasterRunner/
celery multi start w1 -A FasterRunner -l info --logfile=/Users/zd/Documents/FasterRunner/logs/worker.log 2>&1 &

 

stop.sh

#!/bin/bash

# kill django pid
echo -e "shutting down django pid"
pids=$(ps aux | grep "python" | grep "runserver" | awk '{print $2}')
for pid in $pids
do
        kill -9 $pid
done


# kill celery beat pid
echo -e "shutting down celery beat pid"
pids=$(ps aux | grep "celery" | grep "FasterRunner" | awk '{print $2}')
for pid in $pids
do
        kill -9 $pid
done

 二、文件、文件夹从大到小排序

对文件夹、文件从大到小排序:du  -sh * | sort -r  

 三、mac 安装brew

1、sudo vim /etc/hosts

2、在host中加入以下

199.232.28.133 raw.git hubusercontent.com

3、执行命令

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

四、Linux下查找大于1G的文件,并删除

find /APP/istester/ -type f -size +1G | xargs rm

 

posted @ 2020-02-10 15:53  东方不败--Never  阅读(327)  评论(0编辑  收藏  举报