Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
killing a crashed process
06-11-2018, 03:23 PM (This post was last modified: 06-14-2018 05:40 PM by cchen.)
Post: #1
killing a crashed process
When a program crashes, let's say we've got our browser running and all of a sudden it locks up, it may become completely unresponsive. In this case, we can easily kill Firefox and then reopen it, without rebooting the machine. To start off we need to identify the process id:
Code:
[cchen@cchen ~]$ ps aux | grep 'firefox'
cchen     2674  8.4  7.1 2567520 286860 ?      Sl   14:51   1:18 /usr/lib64/firefox/firefox
We can also use the following command to print all the running processes:
Code:
ps -eaf | grep <your ppid> | grep -v grep
Note that you can use "ps -f" to know your ppid

the number next to the owner is the PID (Process ID). We can use this to identify which process to kill. To do so we use:
Code:
kill [signal] pID

There are many other ways to give you CPU and memory usage information in real-time:

P1). "watch -n 1 nvidia-smi" to obtain continuous updates without filling the terminal with output
P2). "ps -ef" will list all the processes. See man ps. See man kill, man 2 kill, man killall, man nice, man pkill, man renice, man 7 signal, and man skill to mess with processes
P3). "top" and "htop"
P4). dstat – Displays a variety of realtime system stats (requires installation)
example: user1@foo ]$ dstat -f (this command displays realtime stats in the system console.)
P5). stat – Display file or filesystem status.
example: user1@foo ]$ stat /home (this command displays the status of the /home directory such as, block size, inodes, links, access and last modified date(s), among other user definable variables.)
P6). du – Displays total disk usage for named directories.
example: user1@foo ]$ du -chs /home (this command displays in user readable format the space usage for the directory /home)

Sometimes this does not work however. the process may still be running. Then we can run kill again but this time supply a signal of 9 which makes sure the process is well and truly gone.
Code:
kill -9 6978

You can also use "free -m" to free memory

You can also use "pvdisplay" to check free space left, or use "df"/"fdisk"/"lsblk" to display total disk usage for mounted file systems, but make sure you are logged in as root

On rare occassions, when a process crashes and locks up, it can lock up the entire desktop. If the GUI has locked up, and we are in luck, we can get to another console and kill the offending process from there. To switch between consoles:
Code:
CTRL + ALT + F<Console>
So CTRL + ALT F2 will get you to a console where you can run the commands as above to identify process ids and kill them. Then CTRL + ALT F7 will get you back to the GUI to see if it has been fixed.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: