NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

Retired_Member's avatar
Retired_Member
Feb 09, 2015

Auto-run of custom unix command (custom wget) on NAS OS

Hello, i am newbie in linux but i know ssh and basic and some advanced commands and i can handle many things with manual :-D

Problem is, that i need to execute 1 basic linux command on my NAS unit READYNAS 312. I DO NEED it to run command repeatedly, in example each 4 hours, or each 1 hour.

wget --user=***** --password=***** http://sledovanitv.cz/vlc/playlist


Code basically downloads CHANNELS PLAYLIST for my IPTV. Dvblink doesnt support HTTP autentificated download, so i have to use this "helpful" script.

I can only acces broadcast / channels from my home IP address. So thats why i use this solution.

As i have checked manually, script works and delivers file. Now i need to automatize it, or hook it up .. somewhere.. give me some hint pls.

19 Replies

Replies have been turned off for this discussion
  • mdgm-ntgr's avatar
    mdgm-ntgr
    NETGEAR Employee Retired
    Ah, looks like the line is formatted incorrectly.

    Perhaps fix the gaps between characters to appropriate lengths. You can see for example the gap between the first and second * is much bigger than the gap between e.g. the 2nd and 3rd one.
  • Retired_Member's avatar
    Retired_Member
    I have taken that line directly fron "crontabs" file, copy and pasted and edited only ending - target script. :-D It only uses tabulators as spaces, thats why it looks (at this forum) broken.

    I have also already tried line, that you have posted here..

    I have also checked files, for encoding, it is UTF8 without BOM, so it is correct and same type as original linux files are.

    I browsed dozens of pages with that fault, but they refer to missing first script line, or problem with paths in linux :( mostly ..

    I am suspicious to problem with paths? But how that could be, if standalone .sh script works ok, if it is run.

    EDIT: this is original crontabs file, just for check, i have never edited it or changed its content, before.

    # /etc/crontab: system-wide crontab
    # Unlike any other crontab you don't have to run the `crontab'
    # command to install the new version when you edit this file
    # and files in /etc/cron.d. These files also have username fields,
    # that none of the other crontabs do.

    SHELL=/bin/sh
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

    # m h dom mon dow user command
    17 * * * * root cd / && run-parts --report /etc/cron.hourly
    25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
    47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
    52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
    #

  • mdgm-ntgr's avatar
    mdgm-ntgr
    NETGEAR Employee Retired
    What happens if you change

    /usr/local/bin/playlist.sh

    to

    sh /usr/local/bin/playlist.sh
  • Retired_Member's avatar
    Retired_Member
    I already had this bright idea, but i have tried once again, with same result.

    I would target on adding cron directly to crontabs. But it is a file. How can i test it? Like i test folders by "run-parts /etc/cron.d" it doesnt work. Is there some way?

    I go sleep now, i have spent whole night with that.. so i like this cron very much.
  • mdgm-ntgr's avatar
    mdgm-ntgr
    NETGEAR Employee Retired
    Asked a friend about this to see if he had any ideas on it and got this response:

    None at all, works for me every way I test it. The only thing that *may* be a problem is that even if one invokes run-parts manually, it will check whether the script is actually up for execution and if it isn't it will simply do nothing. Also, even when script execution is set to "* * * * *" and the script already has been executed within the same minute, run-parts will again do nothing.
  • Retired_Member's avatar
    Retired_Member
    I see, but for me it just DOESNT WORK.

    Because i regularly check target file source code, i know what i am talking about.

    Target file changes only when target .sh script is executed by "sh playlist.sh" manually (i did check target file content again).

    Target file has not changed its content since i went sleep yesterday (10 hours+). So probably, because of nature of links inside the target file (they contain tokens), i will be unable to watch iptv soon again (within 24hours at most).
  • follow this

    1st create a file without extensions in /etc/cron.d for example /etc/cron.d/tvdownload containing


    15 * * * * root /bin/sh /tmp/toto.sh


    toto.sh will be run every hour +15 Minutes

    toto.sh located in /tmp for my example contain :


    /usr/bin/wget --user=toto --password=tooto http://www.xyz.com -O /tmp/index.html


    then do a

    /etc/init.d/cron restart


    you can use this command to monitor

    journalctl -f



    Feb 10 18:15:01 Biniou CRON[8234]: pam_unix(cron:session): session opened for user root by (uid=0)
    Feb 10 18:15:01 Biniou CRON[8235]: (root) CMD (/bin/sh /tmp/toto.sh)
    Feb 10 18:15:03 Biniou CRON[8234]: pam_unix(cron:session): session closed for user root
    Feb 10 18:17:01 Biniou CRON[8270]: pam_unix(cron:session): session opened for user root by (uid=0)
    Feb 10 18:17:01 Biniou CRON[8271]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
    Feb 10 18:17:01 Biniou CRON[8270]: pam_unix(cron:session): session closed for user root
  • Retired_Member's avatar
    Retired_Member
    Good news!

    I have discovered that fact about different EOL (end of lines) that use dos, windows, and unix. Sry i never heard of it and never noticed. I know just various encoding types differencies, but not this. So altough i use notepad++ on windows and then i transfer files to NAS, it was new thing for me and i have just hit "convert EOL for unix" inside this great program and saved both files.

    Then, i have added cron and i have added script to my NAS. Both with empty ending line and now also with correct EOL.

    I have tested through running command "run-parts /etc/cron.d" and it was givimg me still same error (FUNNY). SO THIS CRON TESTING METHOD DOESNT WORK and i warn everyone!

    Because i have waited a few minutes and finally, target file has changed its content (just after schedule time). Voila, problem solved.

    Thanks for your time anyway, it was really hard for me and i believe also for you.. you are patient person. Also big curse is that "ofically described method to test crons" didnt worked.

    And big thanks for CTLJOURNAL -F, because i have discovered error reports with that first, it has reported "info about missing wrong end of lines".
  • mdgm-ntgr's avatar
    mdgm-ntgr
    NETGEAR Employee Retired
    See my previous post for an explanation of why that testing method didn't work for you. Glad it is now resolved.

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More