Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>buliding on user980473's answer I would probably use awk as well, but instead just returning the PID I would call my command and pipe it to bash. Although, I would remove grep and just use awk and move the conditional statement inside the braces.</p> <p><code>ps axo pid,comm,pcpu| awk '/ffmpeg/ {if ($3 &lt;= 15.0 &amp;&amp; $3 &gt;= 10.0) print "kill -9 "$1}' | bash</code></p> <p>notice that my conditional expression is a bit more refined. as user980473's would also print the PIDs greater than 10.0. It appears the working processes of ffmpeg are around 20%? you wouldn't want to kill off those. mine looks at between 10-15%, but that can easily be refined more. You notice <code>awk</code> will than print kill -9 $1 to stdout but, with the pipe to bash these calls will be 'hot'.</p> <p>I am unfamiliar with upstart, but you can more commands. Perhaps you need to call a local python scripit afterwards the command would look virtually the same, but after the $1 you would have "; ./rebootScript.py"</p> <p>or </p> <p><code>ps axo pid,comm,pcpu| awk '/ffmpeg/ {if ($3 &lt;= 15.0 &amp;&amp; $3 &gt;= 10.0) print "kill -9 "$"; ./rebootScript.py"}'</code></p> <p>so this than asks how would you do this? Sitting at the CLI and typing this every 5mins is unresonable. this is where I would set up a cron job. </p> <p>save this file as a bash script</p> <pre><code>#!/bin/bash ps axo pid,comm,pcpu| awk '/ffmpeg/ {if ($3 &lt;= 15.0 &amp;&amp; $3 &gt;= 10.0) print "kill -9 "$1}' | bash </code></pre> <p>NEXT, set the correct permissions. <code>sudo chmod +x ./ffmpegCheck.sh</code></p> <p>and move the script to where you would like to keep it. I would place mine in <code>mv ffmpegCheck.sh /usr/local/bin/ffmpegcheck</code></p> <p>this would allow me to invoke it by simply calling <code>ffmpegcheck</code></p> <p><code>crontab -l</code> or <code>sudo crontab -l</code> for root will display the current cron file..</p> <p>it should look something like this</p> <pre><code># Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command </code></pre> <p>you will want to add an entry to the list. I would type <code>sudo crontab -e</code> but there are other methods. and add <code>*/3 * * * * /usr/local/bin/ffmpegcheck # ffmpeg check</code></p> <p>this will run the script every 3 minutes. This can be configured some. Good Luck.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload