1

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).

Starfish
  • 2,735
  • 25
  • 28
zozo
  • 783
  • 3
  • 11
  • 22

1 Answers1

1
  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.
Sacx
  • 2,581
  • 16
  • 13
  • 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 06 '11 at 09: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 06 '11 at 09:35
  • Still not working -> same crash. Should I provide a video? – zozo Apr 06 '11 at 09:41
  • 1
    add -vo dummy at mplayer commands. – Sacx Apr 06 '11 at 09:45