1

This is my 'automated radio recording' python script.

To run this script, python /path/path/ebs.py Name 1190(length)

And when I type it on terminal, it works perfectly. But When I do it on Crontab.

40 6 * * 1-6 python /Users/myname/Dropbox/ebs/ebs.py Ears 10

I have error report like this.

Traceback (most recent call last):
  File "ebs.py", line 31, in <module>
    recording()
  File "ebs.py", line 23, in recording
    p = subprocess.Popen(rtmpdump)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

#

This is my original script

# coding: utf8
'''
Created on 2015. 9. 5.
'''
import subprocess
import datetime
import sys
import os

def recording() :
    radio_addr = "rtmp://ebsandroid.ebs.co.kr/fmradiofamilypc/familypc1m"
    program_name = sys.argv[1]
    record_mins = sys.argv[2]
    date = datetime.date.today()

    ori_file = '/Users/kimheungbeom/Dropbox/ebs/temp' + str(date) + '_' + program_name
    m4a_file = '/Users/kimheungbeom/Dropbox/ebs/ebs' + str(date) + '_' + program_name + '.m4a'

    rtmpdump = ['rtmpdump', '-r', radio_addr, '-B', record_mins, '-o', ori_file]
    ffmpeg = ['ffmpeg', '-i', ori_file, '-vn', '-acodec', 'copy', m4a_file]
    rm = ['rm', '-rf', ori_file]

    p = subprocess.Popen(rtmpdump)
    p.communicate()
    p = subprocess.Popen(ffmpeg)
    p.communicate()
    p = subprocess.Popen(rm)
    p.communicate()

 if __name__ == "__main__":
    recording()
  • Most probably related to cron offering having a more restricted PATH to the environment. Try to specify the absolute path to the program and it should work – Ricardo Cárdenes Nov 25 '15 at 05:18
  • try replacing with absolute paths (like `/bin/rm` for `rm`) – Ayush Nov 25 '15 at 05:21
  • Oops I forgot to write my cron code. 40 6 * * 1-6 python /Users/myname/Dropbox/ebs/ebs.py Ears 10 – HeungBeom Kim Nov 25 '15 at 05:28
  • @HeungBeomKim That doesn't matter. We're talking about the paths of the programs you are running *within* your script (ffmpeg, rtmpdump, rm). rm should be ok, because it is in /bin, but the others are not being found in the PATH. And yes, it *may* be different for a command line that comes from a login and for a program run from the cron. Trust me, happened to me too many times. – Ricardo Cárdenes Nov 25 '15 at 06:13

1 Answers1

0

Try being specific about where your version of python is and where the location of your script is in the crontab entry.

30,0 * * * * /path/to/python /path/to/your/script
Back2Basics
  • 7,406
  • 2
  • 32
  • 45