1

So the other day I installed Ubuntu 14.04 LTS at home in a partition next to Windows 7. As I'm not able to be at home to watch the Sailplane Grand Prix live as streamed on YouTube, I decided to use livestreamer (http://livestreamer.readthedocs.org/en/latest/) to save it to a file using its -o option.

This works fine (I think - test is running today and I'll see what it looks like when I get home tonight) except that I have to start the command before leaving home in the morning, and the broadcast only starts around mid day, leading to some wasted bandwidth in the morning.

So the obvious thing is to use cron to schedule it, right? Only, when running it from cron it never creates the output file. The cron line I use is this:

38 23 13 05 * ./getfaisgpstream 2> /home/me/getfaisgpstream.log

Like I say, the time comes and goes, and the file /home/me/faisgp20140513 does not appear like it does when running livestreamer from the terminal. I know about the issue where crontab lines need to end in a newline, and I purposefully left a blank line at the bottom of the file to cater for that.

I used crontab -e to change the cron file.

The output I get in "getfaisgpstream.log" is:

./getfaisgpstream: 6: ./getfaisgpstream: livestreamer: not found

The contents of the file "./getfaisgpstream" is:

echo 
echo ======= livestreamer script running to get FAI SGP 2014 stream and save it in home: [`date`]
echo 

while true; do 
  livestreamer --hds-timeout 300 --hls-timeout 300 --rtmp-timeout 300 --http-timeout 300 --http-stream-timeout 300 -fo /home/me/Videos/faisgp`date +%Y%m%d` http://www.youtube.com/watch?v=xmy5VHAvNMg best
  echo ======= livestreamer terminated, restarting [`date`]
  echo; done

echo 
echo ======= livestreamer script exiting [`date`]
echo 

And yes this makes it too robust - but whatever, I'm after a simple hack right now that will solve this for recording the broadcast tomorrow.

3
  • 1
    I would put a script in crontab and put that line in the script. That way you can add "echo"'s to the script and debug it :)
    – Rinzwind
    May 13, 2014 at 12:48
  • 1
    Please edit your question and 1) show the exact cron line you're using 2) Try adding 2> /home/me/logfile.txt and check whether any output is printed to that file. Also, try quoting the URL: livestreamer -o /home/me/faisgp20140513 'https://www.youtube.com/watch?v=xmy5VHAvNMg' best
    – terdon
    May 13, 2014 at 13:37
  • From the error in the .log file, I surmised maybe a permissions problem so I did ls -lh on the livestreamer executable and found this: -rwxr-xr-x 1 root root 326 May 12 21:00 /usr/local/bin/livestreamer
    – Johan
    May 13, 2014 at 21:47

1 Answer 1

2

I found the answer to my question: cron does not get the same environment variables that your terminal does.

It certainly doesn't get your home folder as starting working directory. Therefore, saying...

./getfaisgpstream

...does not work. What you need to do instead, is:

/home/me/getfaisgpstream

Since it also does not get the same path that you do in your terminal, saying...

livestreamer --hds-timeout 300 ...

... does not work either. What you need to do instead, is:

/usr/local/bin/livestreamer
1
  • Thanks, that helped me. It was the PATH that didn't work.
    – marlar
    Dec 5, 2014 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .