Scheduled jobs

  • Hi, I configured a scheduled jobs with this command with the "send email output" enabled:


    Code
    sudo sh /home/pi/raspberry-mcg/script/docker/plex/refresh_lib.sh 5

    each time it is executed I receive an email with this message


    Code
    /var/lib/openmediavault/cron.d/userdefined-014d8449-8363-4241-a6ee-5904509cea43: 31: /var/lib/openmediavault/cron.d/userdefined-014d8449-8363-4241-a6ee-5904509cea43: source: not found


    Going deeper

    Code
    cat /var/lib/openmediavault/cron.d/userdefined-014d8449-8363-4241-a6ee-5904509cea43
    #!/bin/sh -l
    # This file is auto-generated by openmediavault (https://www.openmediavault.org)
    # WARNING: Do not edit this file, your changes will get lost.
    sudo sh /home/pi/raspberry-mcg/script/docker/plex/refresh_lib.sh 5

    and

    Code
    cat /home/pi/raspberry-mcg/script/docker/plex/refresh_lib.sh
    #!/bin/bash
    docker exec plex /usr/lib/plexmediaserver/Plex\ Media\ Scanner -s $1
    echo "Lib number $1 refreshed at $(date '+%Y-%m-%d')";



    Basically each time I execute e bash script that run a command against a docker container and after prints the date.

    I receive above email (I also receive the email with the echo output).


    Thanks

  • No hints?
    Who is using the `source` command to execute scheduled job?

    I see that `userdefined-014d8449-8363-4241-a6ee-5904509cea43` script has `#!/bin/sh -l`, I changed my sh script with this line but I still have the issue

  • Maybe start to simplify:


    sudo - from scheduled jobs you can run the script as root, so no sudo needed

    sh - make the file executable then you don't need sh

    parameter "5" - include it in the script instead of passing it


    Does it work then?


    /home/pi/raspberry-mcg/script/docker/plex/refresh_lib.sh



  • sudo: ok, I can remove it using "root" as user in scheduled job. It comes from the manual command I used to test it.
    sh: ok, in fact I can execute it instead of using sh.

    parameter "5": this could be an issue. Same script is used to refresh different libraries in plex; I'll try putting it inside the script just to see if it solves the issue

  • I made changes suggested.

    Now I have the same issue with another job.
    Mail message is:

    Code
    /var/lib/openmediavault/cron.d/userdefined-fee68f4c-8454-49b2-9d8e-56c8bc8d631a: 31: /var/lib/openmediavault/cron.d/userdefined-fee68f4c-8454-49b2-9d8e-56c8bc8d631a: source: not found

    The command (runned as user `pi`) in gui is:

    I need to run the job with `pi` user to keep permission and ownership (and because I cannot see why I should use sudo).

    Right now I still receive the mail message with `source` command complain

Participate now!

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