shell 实现的自动无限重启脚本,出错自动重启服务

1>forever shell code:


#!/bin/bash

current_dir=$(pwd)
python3dir=$(which python3) 

mainfile=main.py

echo $current_dir
echo $script_dir
echo $python3dir
echo "$python3dir $current_dir/$mainfile;"

until $python3dir $current_dir/$mainfile; do
    echo "Server $mainfile  crashed with exit code $?.  Respawning.." >&2
    sleep 5
done

2>scp 用法


1、从远程复制文件到本地目录。

scp [email protected]:/home/ray/test.py  /home/pi/

 

2、从远程复制目录到本地目录。

scp -r [email protected]:/home/ray/test-prj  /home/pi/

 

3、上传本地文件到远程目录。

scp /home/ray/test-prj.tar.gz  [email protected]:/home/pi/
 

4、上传本地目录到远程目录。

scp -r 
/home/ray/test-prj [email protected]:/home/pi/
 
  



猜你喜欢

转载自blog.csdn.net/zeli1511/article/details/78280884