Files
bn-pc/run_position_closer.sh
2026-02-04 09:46:28 +08:00

33 lines
721 B
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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