Raspberry Pi – adding a cron job to run get_iplayer automatically

Finally getting round to automating my get_iplayer on my pi PVR with cron.

First find where your get_player PVR runs from by typing the following into the terminal

echo $PATH get_iplayer --pvr
my output was: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games get_iplayer --pvr

I had previously tried using:

cd ~/get_iplayer; ./get_iplayer –pvr

but this failed to work, so I recommend the echo path output string.

Next to write the cron job (adding the output file log location)

* 2,14 * * * PATH=./usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games get_iplayer --pvr  >>/home/pi/cron_log.txt

The 2,14 refers to 2am and 2pm, so the command will run at these times. See this wikipedia entry for further explanation and examples. Also note the “.” after the “=” this is required. The second part refers to the process you want to run (eg: run the PVR) and finally the “>” is where to save the output log to.

So now to add the cron job, open the terminal and type

crontab -e

The nano text editor should then open, the just add the line above to automate the PVR and save the output to /home/pi/cron_log.txt so you can check to see that everything is working as expected as the terminal window will not show the processes running. The double “>>” will ensure the new programmes are apended to the file rather than overwriting the file each time the process is run.

Now wait for 2am or 2am and check the log (alternatively set the time for a few minutes in the future to check its all working).

My previous post about get_iplayer here

More info about get_iplayer available on Square Penguin