Cron problem sh file

  • Good day. I'd like to ask for advice. I have a SH script that I would like to run once in a while ..

    if I let it through SSH did what it has and everything works, but if it dam into crontab so does not work.

    Libreelec stable last with RPi3

    my listing looked like this:

    SSH login. write console "crontab -e"

    text to run "* * * * * /storage/.kodi/playlist/"

    ctrl + o save and exit

    The script should get the pairing code from the address and write it to a file in the same directory. but via crontab the file is empty. via ssh command is all right.

    can you please advise it to work via crontab? or is there any other way to run scripts at a certain time?

  • Code
    */10 * * * * /usr/bin/bash /storage/playlists/

    Don't assume the cron environment knows where things are so state /path/to/shell in addition to /path/to/script ^


  • not work... log on cron run script

    /storage/.kodi/playlist/tmobilego/ line 80: jq: not found
    bash: true: unknown operand
    /storage/.kodi/playlist/tmobilego/ line 101: jq: not found
    /storage/.kodi/playlist/tmobilego/ line 102: jq: not found
    /storage/.kodi/playlist/tmobilego/ line 103: jq: not found
    Access token and refresh token saved!
  • So once again .. via SSH script works smoothly and creates a token file. when used in cron the file is created but is empty.

    here is a script where the address is XXXX instead of real values, because of abuse.

    Thank you

    #! /bin/sh
    json=$(wget -qO - ${request})
    status=$(echo ${json} | jq -r '.status')
    sessionid=$(echo ${json} | jq -r '.PHPSESSID')
    echo ${sessionid} > /storage/.kodi/playlist/sledovanitv/


    Mar 15 17:55:00 LibreELEC crond[269]: USER root pid 12198 cmd /usr/bin/bash /storage/.kodi/playlist/sledovanitv/
    Mar 15 17:55:00 LibreELEC crond[269]: /storage/.kodi/playlist/sledovanitv/ line 4: jq: not found
    Mar 15 17:55:00 LibreELEC crond[269]: /storage/.kodi/playlist/sledovanitv/ line 5: jq: not found

    crontab -e (write):

    */5 * * * * /usr/bin/bash /storage/.kodi/playlist/sledovanitv/
  • Well, it would seem you need to install the jq utility

    kodi:~ # which jq
    kodi:~ # jq
    jq - commandline JSON processor [version 1.6]

    Either that or -- and this is the more likely answer -- you need to specify a path in your script or just call jq with an absolute path name instead of relying on $PATH.

    That's where I would start if I were you.


    I just read you said it works when you ssh to the box. That means the second answer I gave is almost certainly the correct one.

  • yes ssh works (system-tools) I have installed. and can you show me where and where to write the path for “jq”?

  • You can include the complete environment:

    */10 * * * * /usr/bin/sh -c ". /etc/profile;exec sh /storage/.kodi/playlist/sledovanitv/"