Skip to content

Instantly share code, notes, and snippets.

@lazydao
Last active April 24, 2024 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazydao/41c05502a431f1f6415215bc41716888 to your computer and use it in GitHub Desktop.
Save lazydao/41c05502a431f1f6415215bc41716888 to your computer and use it in GitHub Desktop.
Linux集子
# 用淘宝源下载python包进行安装
v=$1
wget https://npm.taobao.org/mirrors/python/$v/Python-$v.tar.xz -P ~/.pyenv/cache/
pyenv install $v
# 如果存在目录则清空
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