From 6ffc5fa0fb934b10c48ec9f995509692881ba1cd Mon Sep 17 00:00:00 2001 From: Recolic <git@me.recolic.net> Date: Tue, 24 Dec 2024 01:19:26 -0800 Subject: [PATCH] . --- README.md | 2 +- cron-callback.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 549963b..5fa02f0 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Any of: aria2c / wget / curl 1. Download this repo to anywhere. 2. Modify `init.settings` and `runtime.settings`. -3. Add `* * * * * flock -n /tmp/.vmm.lockfile /path/to/your/cron-callback.sh` into your crontab. +3. Add `* * * * * /path/to/your/cron-callback.sh` into your crontab. ## Supported cloudimg diff --git a/cron-callback.sh b/cron-callback.sh index fd1d988..8c1371f 100755 --- a/cron-callback.sh +++ b/cron-callback.sh @@ -2,7 +2,7 @@ # You may change this directory workdir=./data -ver=1.0.61 +ver=1.0.62 _self_bin_name="$0" function where_is_him () { @@ -165,6 +165,14 @@ function do_start () { done < "$_script_path/runtime.settings" } +# Check if current script is already running. Stupid flock is very unreliable. +for pid in $(pidof -x "$0"); do + if [ $pid != $$ ]; then + echo "$0 : Process is already running with PID $pid" + exit 1 + fi +done + mkdir -p "$workdir" cd "$workdir" || exit $? mkdir -p base vm tmp -- GitLab