I have a virtual machine running CentOS 5.5 that I use as a streaming server.

If I open 4 terminals and do this:

terminal 1:

 # mkfifo pipe1.avi
 # mkfifo pipe2.avi
 # ffserver &
 # ffmpeg -probesize 164000 -i pipe1.avi -async 1 -r 25 http://localhost:8090/feed1.ffm

terminal 2:

 # ffmpeg -i pipe2.avi -async 1 -r 25 -vcodec flv -f flv somename.flv

terminal 3:

 # mplayer -dumpstream rtp://someIp:somePort -dumpfile pipe1.avi

terminal 4:

 # mplayer -dumpstream rtp://someIp:somePort -dumpfile pipe2.avi

Everything is working great. No problems nowhere.

Now I'm trying to make a script and run it from a cron. This is the script:

ffserver &
ffmpeg -probesize 164000 -i pipe1.avi -async 1 -r 25 http://localhost:8090/feed1.ffm &
ffmpeg -i pipe2.avi -async 1 -r 25 -vcodec flv -f flv somename.flv &
mplayer -dumpstream rtp://someIp:somePort -dumpfile pipe1.avi &
mplayer -dumpstream rtp://someIp:somePort -dumpfile pipe2.avi &
exit 0

The crontab line is:

10 * * * * script.sh > /dev/null 1>&2

The problem is that when the cron is run, the system crashes Actually, it doesn't really crash the stream, which I see from another computer and is working perfectly. But, I can't do anything on the machine. The screen becomes black and I can't do anything except restart it. I have a script that kills the anterior processes. If I use it the stream stops, but I still don't regain access to the system (same black screen whatever I do).

  1. Redirect everything to some log files: use command > /home/username/xxx.log 2>&1 & (don't use tmp, because at restart tmp is flushed)
  2. Add some sleep 5 between commands, is possible to to have processes that start slowly and that it will give some time to start in given order (you also can use wait command, but to test, sleep should be enough)
  3. Mplayer is doing that (is taking control of your console). Use -vo dummy to see if is working. If still not working take a look in logs to see if any "terminal" problems appear.
  • I tried to log it. The log is empty (instead of /dev/null I used /var/cronlog.log). How do I add sleep? – zozo Apr 6 '11 at 9:34
  • Use a different log for every command. doing > it will replace the log file, not append it. add sleep 5 after each command and see if is working. – Sacx Apr 6 '11 at 9:35
  • Still not working -> same crash. Should I provide a video? – zozo Apr 6 '11 at 9:41
  • 1
    add -vo dummy at mplayer commands. – Sacx Apr 6 '11 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.