Best Practice to Kill a nohup Task in Linux – Linux Tutorial

By | July 22, 2021

We may use linux nohup command to run a task without terminal and allow it to continue to run with ssl connect closed. However, how to kill this task if you want to stop it? In this tutorial, we will introduce you how to do.

For example, we can use linux nohup command to start a task as follows:

nohup python &

In this command, we will start a python script task: python

If you plant to kill this task, we can do by following steps:

1.Find the task process id

We can use command below to find:

ps -ef

Then we can find:

find linux task using ps command

From the result, we can find this task process id is: 10443. We can use this id to kill this task.

2.Kill a task

We can use linux kill command to stop a task, here is an example:

kill -9 10443

Then we can find that python task is stopped.