LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to start youtube-dl at a later time (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-start-youtube-dl-at-a-later-time-4175653137/)

bajathomas 05-01-2019 05:26 PM

how to start youtube-dl at a later time
 
Hello, Everybody, I am for six years now on Mint, and very happy with the change! As I live high up in the Sierra in BCS, I have a Hughes Sattelite System (archaic), which is very "bandwidth-restrictive", but allows five hours of "free" use from midnight on. I hate getting up at midnight just to press the ENTER key on youtube-dl -a..., but don't know how to solve this problem. As I am 74 and have bad sight, please forgive if a similar question has been overlooked by me and just give me the link.
I would be extremely grateful to you if you could help me out of this "Midnight-Dilemna" and let me sleep again without interruption :-)
Best regards and thanks to all the unknown helpers in the many question &answers sections I have read to great avail these years !!!
Cheers
Thomas

RandomTroll 05-01-2019 05:29 PM

Code:

at
or
Code:

crontab

dan.mera 05-01-2019 06:17 PM

example
 
assumming you have - at - installed. otherwise you need to install it. (via yum, zypper,etc depends on your linux flavor)
you should do this:
echo "youtube-dl http://your link" |at -m 0:05

or if you have multiple ones write them in a file and add it to crontab. if you need help ask and i will give you an example

bajathomas 05-01-2019 10:35 PM

Thanks, Random Troll, but that was very rudimentary and only really useful for "experts", of which I am none :-)

Dan.Mera - thank you so much - have made a trial ready for tonight with one youtube-video. Hope so much it will work !!!
Normally, I use youtubepdl like this:

youtube-dl -ci -f 18 -a z18 (z18 being a file collection)

Can I also use your example, modified like this:

echo "youtube-dl -ci -f 18 -a z18 |at -m 0:05

If YES, that would solve all my earthly problems (almost) :-)

If not, please be so kind and send me the crontab "version"

I am using MINT 19.1 on a Lenovo Laptop

Thank you for your kind attention.

Thomas

RandomTroll 05-02-2019 05:31 AM

Quote:

Originally Posted by bajathomas (Post 5990525)
Thanks, Random Troll, but that was very rudimentary and only really useful for "experts", of which I am none :-)

I wrote it to begin a conversation. Ideally you would have run the man pages for both then, if you couldn't figure it out, ask again.


Quote:

Originally Posted by bajathomas (Post 5990525)
please be so kind and send me the crontab "version"

Run
Code:

crontab -e
Enter
Quote:

1 0 * * * youtube-dl -ci -f 18 -a z18
save (crontab -e will have started an editor) then quit. At 1 minute past midnight every day youtube-dl -ci -f 18 -a z18 will run. Every line in a crontab file has 6 arguments: minute, hour, day, month, day-of-week, file-to-run. If you want to run it only some days or months you can change the *s to specify by name or number days or months. Prepending a # will turn a line into a comment, if you want the line to not-run but don't want to remove if from your crontab file.

bajathomas 05-02-2019 10:36 AM

Thank you very much, Random Troll, now that did help -
will use your cron-"formula" tonight and hope for the best.
By the way, I did check the man-pages after your first post, but what is missing in these pages, IMHO, are a few typicall examples at the end - that would clarify the often very dry and technical (not to say obscure) text - no doubt excellently done, but not for Newbies or old geezers like me who read the screen with strong lenses and a lupa !
Anyway, thanks and will report the moment it works or ask some more dumb questions.
Cheers Thomas

dan.mera 05-02-2019 10:55 AM

typo in your command
 
a small typo in the command should be like this:
echo "youtube-dl -ci -f 18 -a z18" |at -m 0:05

this will need to be typed everytime after you updated your z18 file.
the cron will run daily so you will need to comment the line if you don't want to download something new like this:
crontab -e
and then insert a # before the 1 0 * * * youtube-dl -ci -f 18 -a z18
like this:
#1 0 * * * youtube-dl -ci -f 18 -a z18
until you have a new content in the z18 file and you want another download at midnight.

bajathomas 05-02-2019 03:07 PM

Thank you, Dan, I appreciate your help - I now have a fairly good idea how this works and should be able to get the contraption going tonight.
By the way, I guess I can just leave the cron-order "running" and just switch off the Lap when I go to bed, on those days where there is nothing to download ?! That should work, or don't you think?
Can one use two cron-jobs at the same time? Like:

1 0 * * * youtube-dl -ci -f 18 -a z18
and
1 0 * * * youtube-dl -ci -f 249 -a z249

That would make a more efficient downloading possible -
video- and audio-files at the same time. Just wonder :-)

Tghanks agfain to both Dan and Troll for your time and effort; now I'll try a hell of a lot to get it going :-)

RandomTroll 05-02-2019 04:21 PM

crontab jobs have a limited path. If youtube-dl isn't in the path it'll just report a not found error. To make sure I always supply a full path in crontab. For instance, youtube-dl is in /usr/local/bin on my system; /usr/local/bin isn't in the path crontab uses, so I'd write /usr/local/bin/youtube-dl

Shadow_7 05-02-2019 06:41 PM

$ sleep X; youtube-dl ...

Where X is the number of seconds.

60 = 1 minute
360 = 1 hour

It requires some math, but bash does math on the CLI.

$ echo $(( $(( 60 * 60 )) * 5 )); # AKA 5 hours

Or forgo math and do multiple commands per hour.

$ echo 1; sleep 360; echo 2; sleep 360; echo 3; sleep 360; echo "go"; youtube-dl ...

For those of use too lazy (or paranoid) to use unknowns.

bajathomas 05-02-2019 09:51 PM

SHADOW 7, you nailed it !!!
Immediately got it going and working !!!
And I had started to download some articles and youtubevideos on cron to really "get it" and
be able to use it, but there are so many things
to learn like the path-"declarations" that Troll mentioned etc.pp. - for an old grand-grandfather a big deal.
I understand that "cron" and "at" are the tecnically
more "ambitious" and elegant solutions, but - hell,
this is a solution as simple as it is foolproof ! :-)
Thank you so much for your inspiration -you made my day!!!
How good one feels when a pressing problem is resolved!

My very best reagrds - also to Troll and Dan !
from Rancho Las Palmas en la Sierra de la Giganta, BCS

dan.mera 05-03-2019 09:20 AM

Hi bajathomas, to answer your questions:
the crontab is not executed if the laptop is down.
you can 2 or more lines to use different files, but if they run in parallel then they will slow each other, imagine a pipe through which 2 flows are going at the same time and you want to fill 2 or more buckets at the same time, it will work but patience. this being at night should be fine, hopefully able to complete by 4AM(free time).
good luck!
seen some nice pictures from Rancho Las Palmas en la Sierra de la Giganta

bajathomas 05-03-2019 09:19 PM

Thank you, Dan, although (with the sleep-method) I got lucky last night, and the littemath is no bother, I plan to "make myself more knowledegable" as far as LINUX commands are concerned, and especially cron and at.
So, your helpful hints will be well remembered soon...
In the meantime, I can sleep again quietly and that means a lot for me !
Yeah, this is a nice place, if you like the desert and "bare minimums", as I like to call it, but it has it charm and attraction - I love the quiet and peace, being far away from the madding crowd and having my own water and solar electricity plant, being at least a bit independent...
You probably saw the ad for the sale of the Rancho, eh??
For health reasons (my eyes are fading away = Macular deterioration, and arthritis and gout, nice combo!)
It;s tough, but has to be, I can't manage 150+ acres any more, and got to be nearer to town, Loreto or La Paz,on the outskirts, hopefully being able to find something at least a bit comparable in quiet and independence. Will see


Thanks again for your kind help and take good care of yourself and yours - thesde are trying times and there are dark clouds looming on the horizon...

Best
Thomas


All times are GMT -5. The time now is 12:57 PM.