How to stop an executing script in Linux

WBOY
Release: 2023-05-12 10:25:20
forward
3451 people have browsed it

    linux stops executing the script

    A stress test script bench.sh is being executed, but I want to stop the process midway and no longer execute it.

    You can use ’ps -ef | grep process name‘ to find out the process, and then kill the process.

    How to stop an executing script in Linux

    kill usage: kill [signal code] Process ID

    Note: The signal code can be omitted; our commonly used signal code is -9, which means forced Terminate;

    How to stop an executing script in Linux

    After executing kill, the process is terminated, as follows:

    How to stop an executing script in Linux

    When killing a thread Be careful not to accidentally stop threads that should not be stopped and cause unnecessary trouble. Use this method to stop a thread only when you are reasonably confident.

    linux stop command

    linux stop command method one

    The fastest way to terminate a command currently being executed is to press the key combination "Ctrl C ".

    This method only works if the user can control the program from a virtual console.

    linux stop command method two

    Another way to terminate an error program is to kill its process.

    Please follow the steps below:

    • Enter the "ps" command to get the PID of the process. This command requires you to run this program. That person is either the root user. If you are the root user, enter the "ps -aux" command to view all processes, regardless of who owns them.

    • Find the erroring process in the list. Because the program's name is listed on the far right of the list, you can usually find it at a glance.

    • Please note the leftmost ID number in the process status line in the ps command output list.

    • Enter "kill ID" to terminate the process.

    • Use the ps command to see if the process is still running.

    • If it doesn't appear in the list, you're done. If it's still running, enter "kill 9 ID". This command can achieve the purpose. This command forcibly terminates the process and does not perform any aftermath work, so it is best not to use it unless necessary.

    The above is the detailed content of How to stop an executing script in Linux. For more information, please follow other related articles on the PHP Chinese website!

    Related labels:
    source:yisu.com
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!