使用WHM在Centos 6.5上进行AutoKill处理

I have 3gp files that are uploaded to my server via php. From there FFmpeg will convert the 3gp files to mp3 files. Sometimes the 3gp files are corrupt and FFmpeg will hang on that file and max out that core until the process is killed manually via WHm using the process manager.

There have been times when several of these files bring the server to a grinding halt because ffmpeg has maxed out all cores.

Is there a plugin or script or something I can install on the server that can auto kill any process that exceeds a certain amount of time and 90% cpu?

Centos 6.5 Using WHM I have root access.

There are several ways you can do this based on resource consumption of the process, but I don't think if there is a way to kill the process gracefully. It means that if any of these methods, kill your process, your video may have been compiled half-way. Here are a few suggestions:

  1. Try to nice your FFmpeg process first; this generally solves a lot of problems;
  2. If you want to kill the process definitely, there are some tools for that. One is monit

You just have to programmatically generate pid files for your ffmpeg process and multiple monit configuration.

There is also another tool called cpulimit that you can use to limit CPU usage per process. Here is a link on Ubuntu but I am sure CentOS has it too:

http://ubuntuforums.org/showthread.php?t=992706