22 hours ago22 hr 11 hours ago, Kurotaku said:pidof isn't reliable with scripts because basename might just return names like bash or sh.You could do sth rly simple like that (if you don't mind skipping syncs when another sync is running):#!/bin/bash lock_file="/tmp/scriptname.lock"; if [ -f "${lock_file}" ]; then echo "Script is already running"; exit 1; fitouch "${lock_file}"; echo "Starting rsync process..."; rm -f "${lock_file}";Hey thanks for that example, i'll try that out! I for sure do not wanting it to run twice. What happens is the script catches up to itself due to large files and then it starts deleting the file in progress by the other process. My only question is what happens when I click the abort script, do I need to go delete the lock file manually?
21 hours ago21 hr 17 minutes ago, nerbonne said:Hey thanks for that example, i'll try that out! I for sure do not wanting it to run twice. What happens is the script catches up to itself due to large files and then it starts deleting the file in progress by the other process.My only question is what happens when I click the abort script, do I need to go delete the lock file manually?With abort it would not delete the file, you would need to delete the file first manually, or create another script which deletes it.As for me I personally always just use python scripts.Means the bash script calling py /mnt/cache/scripts/script.py for me, bcs Its much better syntax and you can do much more with python, like checks if the programm already running etc.Just ask Claude/ChatGPT or Gemini to create scripts for stuff like that, thats what I do on daily basis.As I'm currently working on a big and maybe last major release version of User Scripts Enhanced, I will may in the future create a Standalone version for User Scripts Enhanced which allows then for me to implement stuff like this, that you can't start the same script at the same time by default. But that will take a lot time, and first my other 2 new Plugins must be finished :) Edited 21 hours ago21 hr by Kurotaku
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.