

Making trouble (simulating CPU load)ĭying to see top in action but, wouldn't you know it, everything is running smoothly? The top display can be customized in real time through keyboard input. Time stolen from this VM by its hypervisor (host) Time running low-priority (nice) processes Time running high-priority (un-niced) processes Here's a quick rundown of the jumble of acronyms you'll see there: Metric In case you ever need them, the third line of top output you saw a bit earlier gives us time values (as percentages) for a number of other CPU metrics. Of course, you'll also have to run systemctl disable to make sure the process doesn't restart the next time you boot. Before launching killall, make sure there aren't any similarly named processes you still want running that could become "collateral damage." So if there were two or three separate MySQL instances-perhaps belonging to separate users-all would be stopped. kill will shut down a single process, based as it is on the PID, while killall will kill as many instances of a particular program as are running.

To kill or to killall, that is the question. Killall, on the other hand, uses the process name rather than its ID.

You pass the PID to kill this way: kill 1367 Some systems require you to install killall as part of the psmisc package. If the process you want to shut down is not managed by systemd, or if something's gone wrong and systemctl failed to stop it, then you can use either kill or killall to eliminate your process.

Since MySQL is a service managed by systemd (on those distros using systemd), your first choice should be to use systemctl to bring the process down gently without putting any application data at risk. That top display gave you everything you'll need to kill it. Perhaps you'll conclude that this process was taking more resources than can be justified and will have to be sacrificed (for the greater good, you understand). If you follow that row over to the left, you'll see that the process ID (PID) is 1367 and the process is "owned" by the mysql user. In this case, you can see that the MySQL daemon is using 4.3% of the server's CPU and, from the next column, 13% of its memory. You'll especially want to note the processes showing up at the top of the list. Since we're trying to resolve performance problems, the columns of data that should interest us the most are %CPU (percentage of CPU capacity currently used by a given process) and %MEM (percentage of memory capacity).
