I clicked on a.out of a code in Linux, now I want to stop running code but as I didn't use the terminal, I don't know that how can I stop the code from running. What can I do? I am running another code from last week. I can not kill both by turn off the computer because the first code is running from previous week and I don't have time to run it again
Asked
Active
Viewed 673 times
-6
-
1ctrl+c combination? – Andrey Semenov Nov 10 '17 at 18:04
-
3Time to learn about the `kill` command. – tadman Nov 10 '17 at 18:04
-
1Turn off the machine – Davy M Nov 10 '17 at 18:04
-
I'm running another code in terminal and I afraid if I press ctr+c that code stop running @AndreySemenov – Mathe Ma Nov 10 '17 at 18:04
-
I am not sure but `ps -ef | grep
` may help. Kill the resulting process id. – Sid Nov 10 '17 at 18:05 -
I can not. Because I am running another code @DavyM – Mathe Ma Nov 10 '17 at 18:05
-
I don't know the process name @Sid – Mathe Ma Nov 10 '17 at 18:06
-
@MatheMa Kill both, don't care. Rinse, flush, start over. Process name is `a.out` BTW. – user0042 Nov 10 '17 at 18:06
-
This may help @MatheMa : https://stackoverflow.com/a/11934701/259889 – Sid Nov 10 '17 at 18:07
-
I can not kill both because the first code is running from previous week and I don't have time to run it again @user0042 – Mathe Ma Nov 10 '17 at 18:07
-
@MatheMa Good experience to learn, naming your programs different than `a.out`. Well, you can check the PID. A common heuristics says that the PID of the incidentially started process should be bigger than your precious long runner. – user0042 Nov 10 '17 at 18:10
-
Please provide an exact answer, I do really need your help because my computer will damp if both run together – Mathe Ma Nov 10 '17 at 18:14
-
What should I do after that? please help me I really afraid that computer dump :( @user0042 – Mathe Ma Nov 10 '17 at 18:19
-
pidof a.out output is: 19564 7735 @user0042 – Mathe Ma Nov 10 '17 at 18:19
-
@MatheMa So the question is which is the bigger number? – user0042 Nov 10 '17 at 18:23
-
Is it correct to use 'pidof a.out ' to find pid of the process I ran by mistake? @user0042 – Mathe Ma Nov 10 '17 at 18:25
-
Open a terminal and run `pgrep a.out`, what does it say? – yacc Nov 10 '17 at 18:33
-
@yacc 7735 19564 – Mathe Ma Nov 10 '17 at 18:36
-
Run `ps -ef | grep a.out` what does it say? – yacc Nov 10 '17 at 18:38
1 Answers
0
So, if you're running two instances of a.out (which I'm just assuming because your question is unclear...) then, as other users have said, run:
pgrep a.out
If the second a.out process is the one you want to kill, take the larger PID number (in your case it seems to be 19564) and run:
kill 19564

samuelnj
- 1,627
- 1
- 10
- 19