常用命令

2021/11/10

更全的命令可以看:api大全 (opens new window)

# 变量

# 条件判断

  • shell的数字、字符串、文件的判断写法都不一样

# 执行流程

# 时间

echo `date`

# 格式化时间
echo `date "+%H:%M:%S"`

# 指定时间做事
while true
do
    sleep 1

    # 注:加双引号格式化成字符串,不加双引号格式化成数字
    current=`date "+%S"`
    echo ${current} >> log.txt
    if test ${current} -eq '11'; then
        echo `date "+%H:%M:%S"` >> log.txt
    fi
done
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# 自动部署脚本

  • pm2启动
PATH_DEPLOY=/usr/local/html
PATH_ROOT=/home/app/loan
PATH_PROJECT=/home/app/loan/02_src/cash-loans-front

update() {
    cd ${PATH_ROOT}
    git pull
    cd ${PATH_PROJECT}
    npm i
    npm run build-only
    mv ${PATH_DEPLOY} ${PATH_DEPLOY}_temp
    mv ./dist ${PATH_DEPLOY}
    rm -rf ${PATH_DEPLOY}_temp
    echo "完成更新:" `date +"%Y-%m-%d %H:%M:%S"` >> log.txt
}

update

while true
do
    current=`date +%H`
    if test ${current} -eq '03';then
        update
    fi

    sleepTime=`expr 60 \* 58`
    # sleepTime=`expr 60 \* 3`
    sleep ${sleepTime}
done
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
上次更新: 9/17/2024