问题
I'm running R in interactive mode under linux, and mistakenly typed in a command that takes forever to run. I usually stop it using ctrl+c. But it doesn't work all the time. When it doesn't work, is there another way? I don't want to kill the R session to start over either.
Thanks.
回答1:
I have had the problem you mention. ctrl+c
will work when R
is able to realize "oh this guy wants me to stop running that particular command." However, often R
cannot do that. So you have to run ctrl+\
(note that it's a backslash not a forward slash). This tells linux
"hey, R
is not listening to me, can you stop running R
?".
Try ctrl+c
first because if it works you will still have your R
session. If it doesn't work, and you do ctrl+\
you will lose your R
session but at least stop the process.
If that doesn't work either, then I would suggest a killall R
or a kill -9 [PID]
where you find the PID by running pus aux
.
回答2:
Try to use ctrl+c, then pause R with ctrl+z, and then unpause R with fg (#job)
I tried the solutions given above with sending some signals to R with kill, but neither worked. Then I tried the sequence above (ctrl+c; ctrl+z, fg 1) and it worked. I could continue the R session. I'm not sure whether it was one of the signals or ctrl+c that stopped R, but I guess ctrl+z was essential here.
回答3:
You can also try
kill -USR1 [pid]
This will interrupt some R calls and sometimes give you the option to save and quit rather killing the process all together.
回答4:
ctrl+c not working. Somehow ctrl+\ will stop the process. But there is a fuction in r programming to quit. You can try q() on RPEL, worked for me.
q()
来源:https://stackoverflow.com/questions/9337825/how-to-stop-a-running-r-command-in-linux-other-than-ctrlc