dd-wrt and leech in cron job

Issue #3 invalid
dr crs created an issue

Hi alekseyt, at first thanks very much for you work.It s very usefull. I have an issue, I hope that you can help me:

I am using leech with transmission in a dd-wrt router (v24 sp2). If I execute from prompt it works fine, no problems. But I want to add leech to crontab. I did it from dd-wrt web interface. this is the original job:

/30 * * * root CONFIG_DIR="/opt/etc/leech" DOWNLOADS_DIR="/mnt/sda_part3/Torrents" /opt/usr/sbin/leech

This command works fine If you execute It, but in cron It shows Failed: 127

Trying , I modified the job to:

/30 * * * root PATH="/sbin:/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/usr/bin:/usr/sbin:/opt/usr/local/bin" CONFIG_DIR="/opt/etc/leech" DOWNLOADS_DIR="/mnt/sda_part3/Torrents" /opt/usr/sbin/leech > /opt/etc/leech/log.txt

I added PATH like root user and a log. Now, it shows FAILED: 16

I could not find this error code, I don't know what it means. Tried to add SHELL and other env vars, but it didnt work

Do you know where can be the problem?

Thanks in advance!

Dr Crs

Comments (6)

  1. Aleksey Tulinov repo owner

    Could you also redirect stderr to a log, as in adding "2>&1" to the end of cron job (reference: https://bitbucket.org/alekseyt/leech#markdown-header-it-works-from-command-line-but-doesnt-work-in-cron).

    If it doesn't help to diagnose this issue, please consider sharing complete execution log (/opt/etc/leech/log.txt), because i don't completely understand at what step error appears. If you think sharing this log publicly might compromise your privacy, please consider anonymizing it or emailing it to me.

  2. dr crs reporter

    Thanks Aleksey for your reply I redirected the stderr and this is the error:

    curl: can't load library 'libcurl.so.4'

    I searched for that library and it is in /opt/usr/lib. I added this directory to the PATH in the cron job, but the error persists. This is the cron job

    /30 * * * root PATH="/opt/usr/lib:/sbin:/opt/bin:/opt/usr/bin:/opt/sbin:/opt/usr/sbin:/bin:/usr/bin:/usr/sbin:/opt/usr/local/bin" CONFIG_DIR="/opt/etc/leech" DOWNLOADS_DIR="/mnt/sda_part3/Torrents" /opt/usr/sbin/leech >>/opt/etc/leech/leech.log 2>&1

    Thanks! Cristian

  3. Aleksey Tulinov repo owner

    Cristian, i think path to shared library need to be added to LD_LIBRARY_PATH instead, but don't quote me on that. While using OpenWRT i'm using this script: https://forum.openwrt.org/viewtopic.php?pid=108500#p108500

    What this script does: basically symlinks all binaries and libraries from external root into root filesystem (ln -sf /opt/usr/lib/libcurl.4.so /usr/lib/), but it does this for entire installed packages. I don't know if there is any alternative available for DD-WRT, but it seems that you have curl installed to something similar to external root (/opt) and its not visible from cron's environment.

    You could try to set LD_LIBRARY_PATH or link libcurl manually. Or setup environment for cron in the way similar to your shell (bash? ash?). I suspect that your /root/.profile might set PATH and LD_LIBRARY_PATH and you might try to source /root/.profile && CONFIG_DIR=... in your cron job.

    If this doesn't help, then my best bet would be DD-WRT support forum, i'm afraid i don't have enough expertise in DD-WRT to give a specific suggestion.

  4. dr crs reporter

    Hey Aleksey, I tried setting the LD_LIBRARY_PATH and it is working like a charm! Thanks a lot for all, For your leech and for your time.

    Cheers! Cristian

  5. Log in to comment