编写如下run.sh文件,内容如下
#!/bin/bash
export PATH=/root/anaconda3/bin$path
nohup python -u 文件名.py >>out.log 2>&1 &
#! /bin/bash
conda activate 虚拟环境名
cd 待执行脚本文件路劲
nohup python -u 文件名.py >>out.log 2>&1 &
#!/bin/bash
nohup python -u sche_test.py >>sche_test.log 2>&1 &
nohup python -u start_ascheduler1.py >>start_ascheduler1.log 2>&1 &
sche_test.py
import time
fsave = open("1.txt", "a")
for i in range(1000000):
print("ascheduler1--------------------", i)
con = "ascheduler1--------------------", i
fsave.write(str(con) + "\n")
fsave.flush()
time.sleep(5)
sche_test.sh
我是在 docker容器里使用的
#!/bin/bash
nohup python -u sche_test.py >>sche_test.log 2>&1 &
source sche_test.sh
参考:
https://zhuanlan.zhihu.com/p/363531715