diff --git a/README.md b/README.md index 549963b5ed500a56b069abd8d07102d635dbd46e..5fa02f026224f354e978101b0bb4dbfda25b0200 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 fd1d98830203975f5b6e23a2560968038da2b034..8c1371f7536ed5e19af4bc418c20029f350aa6cc 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