• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • How to forcefully stop and kill a process in Linux

    There are times when a process hangs or is responding very late when you feel like killing the process. The ultimate solution is to find the process id of the respective process and kill the same but below list of steps can also be used.

    How to forcefully stop a process?

    You can use "Ctrl + Z" to forcefully stop a process as used below
    # yum whatprovides */python-deltarpm
    Loaded plugins: product-id, search-disabled-repos, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Repository RHEL is listed more than once in the configuration
    RHEL                                                   | 2.9 kB  00:00:00
    RHEL/primary_db                                        | 3.7 kB  00:00:00
    RHEL/filelists_db                                      | 2.2 kB  00:00:00
    No matches found
    ^Z
    [1]+  Stopped                 yum whatprovides */python-deltarpm

    Now stopping this way does not means that the process is killed. If I see list of process
    # ps aux | grep -i yum
    root     10511  2.8  1.7 422324 71476 pts/2    T    19:09   0:00 /usr/bin/python /usr/bin/yum whatprovides */python-deltarpm
    Here as we see the stat shows "T" which means stopped.





    How do we list stopped processes?

    By executing "jobs" command as below
    # jobs
    [1]+  Stopped                 yum whatprovides */python-deltarpm

    This command will list you all the process which are in stopped state

    How to kill a stopped process?

    Here we need to use the identifier which is assigned to each stopped process. Here in our case as we see the identifier is [1]

    So the command to kill this particular process would be
    # kill %1

    [1]+  Stopped                 yum whatprovides */python-deltarpm

    Immediately now if I try to see the list of available stopped processes
    # jobs
    [1]+  Exit 1                  yum whatprovides */python-deltarpm

    Here now it is trying to Exit as we see above

    Again after few seconds if I give the same command
    # jobs
    No output so I do not have any stopped processes

    I hope this article was useful.

    Related Articles

    Follow the below links for more tutorials

    How to secure boot loader (grub menu) with password in RHEL 6
    How to check last login time for users in Linux
    What is the difference/comparison between Unix and Linux ?
    RAID levels 0, 1, 2, 3, 4, 5, 6, 0+1, 1+0 features explained in detail
    Step by Step Linux Boot Process Explained In Detail
    What is GRUB Boot Loader ?
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?
    What is kernel-PAE in Linux?
    What is swappiness and how do we change its value?
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    How to do Ethernet/NIC bonding/teaming in Red Hat Linux
    How to install/uninstall/upgrade rpm package with/without dependencies
    What is the difference between ext3 and ext4 filesystem in Linux ?

    How to forcefully stop and kill a process in Linux How to forcefully stop and kill a process in Linux Reviewed by Deepak Prasad on Sunday, May 21, 2017 Rating: 5

    No comments:

    Powered by Blogger.