[{“source”:{“position”:0,“lines”:["<p style="">在 root 下添加为开机自启(使用 systemd,服务以 root 身份运行)。将下面内容写入 /etc/systemd/system/liu_btc_trade_strategy.service 并启用:
- <p style="">创建 unit 文件:
sudo tee /etc/systemd/system/liu_btc_trade_strategy.service > /dev/null <<‘EOF’"]},“target”:{“position”:0,“lines”:["<p style="">在 root 下添加为开机自启(使用 systemd,服务以 root 身份运行)。将下面内容写入 /etc/systemd/system/okx_multi_account.service 并启用:- <p style="">创建 unit 文件:
<p style="">Codesudo tee /etc/systemd/system/okx_multi_account.service > /dev/null <<‘EOF’"]},“type”:“CHANGE”},{“source”:{“position”:2,“lines”:[“Description=liu_btc_trade_strategy Python service (run as root)”]},“target”:{“position”:2,“lines”:[“Description=okx_multi_account Python service (run as root)”]},“type”:“CHANGE”},{“source”:{“position”:8,“lines”:[“WorkingDirectory=/home/liu”,“ExecStart=/usr/bin/python3 /home/liu/liu_btc_trade_strategy.py”]},“target”:{“position”:8,“lines”:[“WorkingDirectory=/home/auto_trade”,“ExecStart=/usr/bin/python3 /home/auto_trade/okx_multi_account.py”]},“type”:“CHANGE”},{“source”:{“position”:18,“lines”:[“sudo systemctl enable –now liu_btc_trade_strategy.service”,"
<ol start="3"><p style="">管理与查看: <p style="">Codesudo systemctl status liu_btc_trade_strategy.service",“sudo journalctl -u liu_btc_trade_strategy.service -f”,“sudo systemctl stop liu_btc_trade_strategy.service”,“sudo systemctl disable liu_btc_trade_strategy.service”,"
<p style="">注意:- <p style="">确认 /home/liu/liu_btc_trade_strategy.py 可被 root 读取并可运行(通常 root 有权限)。
- <p style="">若脚本需虚拟环境或特定 PATH,把 ExecStart 改为该虚拟环境的 python 路径。
<p style="">"]},“target”:{“position”:18,“lines”:[“sudo systemctl enable –now okx_multi_account.service<ol start="3">sudo systemctl status okx_multi_account.service”,“sudo journalctl -u okx_multi_account.service -f”,“sudo systemctl stop okx_multi_account.service”,“sudo systemctl disable okx_multi_account.service”,"<p style="">注意:- <p style="">确认 /home/auto_trade/okx_multi_account.py 可被 root 读取并可运行(通常 root 有权限)。
- <p style="">若脚本需虚拟环境或特定 PATH,把 ExecStart 改为该虚拟环境的 python 路径。