Every now and then (every few days) I notice that a process is using 100% CPU. The process is avrdude started by the Arduino IDE which, under certain circumstances that I haven't been able to reproduce just sits there at 100% CPU as shown in top.Possibly the circumstances are that an upload to the Arduino board commences, and the board is disconnected during the process.I have 8 cores in the processor, so it isn't immediately obvious that one of them is maxed out. In fact, it only becomes noticeable if it happens a few times in a row, and then I have maybe 3 cores at 100% CPU.Is there a way of having some background task check for this (say, every 15 minutes), and then alert me in some way (eg. some pop-up dialog)? I am using Ubuntu 14.04 LTS.Thanks to MelBurslan for his answer, but I'm stumped as to why it isn't fully working. My current script is this:cpupercentthreshold=2pstring=top -b -n 1 | sed -e 1,7d | while read line; docpuutil=$(echo ${line} | awk '{print $9}' | cut -d. -f 1)procname=$(echo ${line} | awk '{print $12}' )if [ ${cpuutil} -ge ${cpupercentthreshold} ]then  echo ${cpuutil}  pstring=${pstring}${procname}   echo pstring is currently ${pstring}fidoneecho pstring is ${pstring}if [ -n ${pstring} ]then  zenity --title=Warning! --question --text=These processes are above CPU threshold limit ${pstring} --ok-label=OKfiI dropped the threshold down for testing. However as you can see it collects the individual processes OK, but the final test (to display the dialog box) fails because pstring has suddenly become empty for reasons I can't see:13pstring is currently VirtualBox6pstring is currently VirtualBox Xorg6pstring is currently VirtualBox Xorg compiz6pstring is currently VirtualBox Xorg compiz ibus-engin+6pstring is currently VirtualBox Xorg compiz ibus-engin+ toppstring is
How to detect and warn if a process is using 100% CPU for a long time?
linux;monitoring;cpu usage