添加启动命令

This commit is contained in:
yhydev
2026-02-04 09:46:28 +08:00
parent 1f95493449
commit d049acb3ad

32
run_position_closer.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# 运行 position_closer.py可选每 1 小时循环一次。
# 用法:
# ./run_position_closer.sh # 运行一次
# ./run_position_closer.sh loop # 每 1 小时运行一次(前台循环)
# 配合 crontab 每小时运行一次: 0 * * * * /path/to/bn-pc/run_position_closer.sh
set -e
cd "$(dirname "$0")"
if [[ -x .venv/bin/python ]]; then
PYTHON=".venv/bin/python"
else
PYTHON="python3"
fi
run_once() {
set +e
"$PYTHON" -m position_closer
set -e
}
if [[ "${1:-}" == "loop" ]]; then
echo "每 1 小时运行一次 position_closer按 Ctrl+C 停止"
while true; do
run_once
echo "下一轮于 1 小时后执行..."
sleep 30
done
else
run_once
fi