Schedule not, if already running

  • Hello,


    I run a scheduled Command:


    docker exec -i rclone-browser sh < /home/test.sh


    So it is a rclone job in an Docker container. ( [HOWTO] Rclone via docker )


    But I have the problem, that rclone get problems, if a scond instance of the script is running. So, ist there a way to avoid a second instance?


    I tried things like this in the text.sh:


    if pidof -x "abc.sh" >/dev/null; then echo "Process already running"fi


    But I get an error in the moment I put code in test.sh.


    test.sh at the moment:


    /usr/bin/rclone bisync DRIVE1:/test Drive2:test --verbose --multi-thread-streams 4 --stats-file-name-length 0 --fast-list


    This is running fine, but where can I avoid a second instance of the script? In test.sh or in OMV? An how?


    Best Tom


    8balljunkie

  • in test.sh

    Check if a lock file / pid file exists

    Create a lock file / pid file

    run rclone

    remove lock file

    If you got help in the forum and want to give something back to the project click here (omv) or here (scroll down) (plugins) and write up your solution for others.

  • You can probably do this with a file or with a global variable and in you cron job test if the variable=true or file exist.

    What do you mean? trap and how to use it is explained in the link.

    If you got help in the forum and want to give something back to the project click here (omv) or here (scroll down) (plugins) and write up your solution for others.

  • I don't know how trap works.


    I would take this approach:


    In your script set something as a flag in different log file and every time your script starts it would check the log file if an instance is running.
    When your script ends it would unflag the logfile and a new instance can start running the process and again flagging that it's running.

  • Hi,


    I got it to work (Rsync sets flags itself and can prevent re-running), but unfortunately it kept giving various errors. So Rsync is unfortunately no longer a reliable way for me to sync in two directions.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!