NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
Retired_Member
Feb 09, 2015Auto-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.
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.
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-ntgrNETGEAR Employee RetiredHave you tried using cron?
- Retired_MemberNot yet.
I know what CRON is. I am using it with relation to web sites, web hosting and running php scripts there.
But at NAS? I have meanwhile discovered following directories, in directory structure:
/etc/cron.d
/etc/cron.daily
/etc/cron.monthly
/etc/cron.weekly
and file
/etc/crontab
Is there some reference how to use this feature ? All the directories, where i was looking for example file, or inspiration, were empty. Or some manual or else forum page, where it could be described?
I really need just to add that command above to be run each 1 hour. Or maybe 4 hours. Nothing else. - mdgm-ntgrNETGEAR Employee RetiredCron is used on many different unix systems for scheduling tasks. There is plenty of information on this available on the web.
- Retired_MemberYes, i know, but you could save me a 10 hours of searching.. testing and then fixing my NAS, if something goes terribly wrong.
Maybe this forum was intented to be made for helping people who invested into netgear's products, but then "something has happened" too. - mdgm-ntgrNETGEAR Employee RetiredThings like this are SSH hacks and with these you are expected to have some willingness to find out how to do some things by yourself. Otherwise you probably shouldn't be using SSH.
03 */4 * * * /usr/bin/wget --user=***** --password=***** http://sledovanitv.cz/vlc/playlist
Something like this ought to do it. Best not to run a cron script right on the hour. - Retired_MemberOk thanks very much. :oops: Yes i have discovered a big number of nice manuals, but when i started searching for solution there (i mean writing code inspired by manuals) it became very stressful process.
I have also discovered, that linux VI editor has been probably replaced with its some newer version inside NAS OS 6.1.9 and i am even unable to switch it from command mode to edit mode now. OMG. These newer versions :slap:
So basically when was trying to help myself alone, only other more and more problems and difficulties, have appeared. Yes i am awared, that the source is my lack of skill and experience with unix systems.
So I have created file called "playlist" which is placed inside /etc/cron.hourly/ and contains only this line:wget --user=***** --password=*****http://sledovanitv.cz/vlc/playlist -O /apps/dvblink-tv-server/share/playlist
I was not absolutely sure, if script is executed every hour, but i am convinced, because locally saved file (playlist) changes its content regularly and solution works. Yes it would be nicer to run it not exactly on each hour X:00. - mdgm-ntgrNETGEAR Employee RetiredInstructions for using vi are on the MAN page for it which you can find using google on the web. There is also a vi cheat sheet on the web.
Try creating a file in /etc/cron.d with the contents I suggested above. - Retired_MemberHello, yes i know that VI, has online manual and i was already browsing it before, but i found it not user friendly at all and i was unable to find there the switch button key, between edit, insert modes (any other then escape, or insert maybe). They have changed this completely between versions, now it is painful to use it, so i cant use it at all.. Previous versions worked very well and seamless. Back to topic..
i realized, that my file was not run repeatedly by cron, it wasnt run repeatedly at all.
So i have created file "playlist" inside "cron.d" directory with the following content:03 */4 * * * root /usr/bin/wget --user=*** --password=*** http://sledovanitv.cz/vlc/playlist -O /apps/dvblink-tv-server/share/playlist
- i have tried both with ROOT user typed in (above) and or without it
but problem is, that if i run it by command "run-parts /etc/cron.d/" then it returns execute error, code1.
I have set "chmod +x playlist" for it.
I have also tried to rename "playlist" file inside cron.d folder to "playlist.sh" and then "chmod +x", but then when i run-parts, it gives no error code and target file doesnt change. (so it is not executed OK)
When i have tried multiple times to run the command standalone, it works ok and changes file content (here) /usr/bin/wget --user=*** --password=*** http://sledovanitv.cz/vlc/playlist -O /apps/dvblink-tv-server/share/playlist[/code]
EDIT: only bright idea, i currently have, is to put whole command into .sh file and let cron to execute just this .sh file.. if that can make any difference? I will test and post results.
EDIT2: it doesnt work. Execute error code 1, altough standalone running .sh script works. This is exactly what i hate about linux...
#!/bin/sh
/usr/bin/wget --user=mail@address.com --password=***** http://sledovanitv.cz/vlc/playlist -O /apps/dvblink-tv-server/share/playlist - mdgm-ntgrNETGEAR Employee RetiredDid you remember to add a blank line to the end of the script?
- Retired_MemberI have added empty line to both files.. (one in cron.d directory) called playlist
6 * * * * root /usr/local/bin/playlist.sh
and the second file with script itself called playlist.sh
#!/bin/sh
/usr/bin/wget --user=mail@address.com --password=***** http://sledovanitv.cz/vlc/playlist -O /apps/dvblink-tv-server/share/playlist
but result is still
run-parts: failed to exec /etc/cron.d/playlist: Exec format error
run-parts: /etc/cron.d/playlist exited with return code 1
Related Content
- Nov 30, 2019Retired_Member
NETGEAR Academy

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