Help with setting up snapraid custom cron job

  • Hi,


    I am looking to configure a custom snapraid-diff script. I am not proficient with Linux so please bear with me.


    The script i wish to test is the one located here


    https://gist.github.com/mtompkins/91cf0b8be36064c237da3f39ff5cc49d


    I created a "scripts" directory in /usr/local/


    mkdir /usr/local/scripts


    I created a file called snapscript.sh in /usr/local/scripts/


    nano /usr/local/scripts/snapscript.sh


    I copied the code in the link above into snapscript.sh and saved it


    I then went into the omv-gui and did the following



    However, when i hit the "run" button i get the following error



    Can someone kindly explain where I am going wrong?

  • messier63

    Hat das Label OMV 5.x hinzugefügt.
  • I copied the raw file directly into snapscript.sh using nano. Then made the changes to the user settings within the script.


    Now, the permissions bit is something i did not think about.

    I am logged into my server as root via putty, using the root credentials created during the installation process.

    If i created the file as root in putty, shouldn't the file permission be fine for root to read, write and execute when the cron below is executed?

    Anyway, i did the following to give root exexutable permission

    Code
    root@test:~# ls -l /usr/local/scripts/
    total 16
    -rw-r--r-- 1 root root 15637 Mar  1 00:25 snapScript.sh
    
    root@test:~# chmod -v u+x /usr/local/scripts/snapScript.sh
    mode of '/usr/local/scripts/snapScript.sh' changed from 0644 (rw-r--r--) to 0744 (rwxr--r--)

    Doing the above still gave me the same error

  • chmod -v u+x /usr/local/scripts/snapScript.sh

    Why the -v flag?

    AFAIK chmod doesn't have that flag.


    Use chmod +x /usr/local/scripts/snapScript.sh


    And check it with ls -al /usr/local/scripts/

  • The -v flag i picked up from a site explaining chmod

    I removed the flag and it seems to be working when i used the following command to give only root execute access.


    chmod u+x /usr/local/scripts/snapScript.sh


    To check if the error is repeatable i removed root execute access and it threw up the error in my initial post.


    Last query on scripts, where is the most appropriate directory to store custom scripts like the snapScript.sh used above?

  • Last query on scripts, where is the most appropriate directory to store custom scripts like the snapScript.sh used above?

    Good question.

    Depending on the user that the script will belong to, you can have it anywhere as long as you know where they are.

    If it's scripts that belong to a specific user, just put them on their respective /home, maybe.


    You can also make a folder and put them all inside, for eg.

    mkdir /myscripts

  • This particular script keeps hanging for some reason at the following position



    I am not sure what is going on here so I'll have a look for another script that works on my test bench

  • messier63

    Hat das Label gelöst hinzugefügt.
  • Could be the script is hanging on a missing dependency. I modified my copy as follows:


    I suggest installing the discount package and making the below change in the script:


    Code
    Change this line from:
    $MAIL_BIN -a 'Content-Type: text/html' -s "$SUBJECT" "$EMAIL_ADDRESS" < <(python -m markdown $TMP_OUTPUT)
    
    
    Change to:
    $MAIL_BIN -a 'Content-Type: text/html' -s "$SUBJECT" "$EMAIL_ADDRESS" < <(markdown $TMP_OUTPUT)

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!