Last active
April 24, 2024 05:49
-
-
Save lazydao/41c05502a431f1f6415215bc41716888 to your computer and use it in GitHub Desktop.
Linux集子
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 用淘宝源下载python包进行安装 | |
v=$1 | |
wget https://npm.taobao.org/mirrors/python/$v/Python-$v.tar.xz -P ~/.pyenv/cache/ | |
pyenv install $v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 如果存在目录则清空 | |
test -d $log_dir && rm -rf $log_dir/* | |
# 如果不存在目录则创建 | |
test ! -d $log_dir && mkdir $log_dir | |
# 查看端口占用 | |
netstat -tunlp | grep 端口号 | |
lsof -i:端口号 | |
# 启动脚本至后台,记录pid | |
nohup python3 -u main.py & echo $! > pidfile | |
# 重启脚本并备份log | |
kill -2 `cat pidfile` | |
test ! -d log && mkdir log | |
baklog=log/`date +'%Y-%m-%d-%H-%M-%S'`.log | |
mv nohup.out $baklog | |
nohup python3 -u main.py & echo $! > pidfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment