I'm logged into a remote server (server is CentOS, I'm on Ubuntu). I executed the following command:
nohup bash script.sh > log.txt &
script.sh contains, simplified, this content:
for q (some condition that will trigger about 60 times)
do
sed (change config file for some other program depending on q)
execute some other program (each call of this other program takes about 25 minutes)
done
Unfortunately I realized there was a small error in the other program. I fixed it with no trouble but I am having trouble actually killing this script so I can start it over with the fixed other program. When I did the nohup bash script.sh at the beginning, it popped out a number 1946, which I assume is the pid for script.sh. I did:
pkill 1946
That stopped the OTHER PROGRAM that script.sh calls (I can tell from the logfile it creates). But then, script.sh calls the next iteration of the other program. I can tell because the logfile that script.sh makes tells me, and also, the other program uses my GPUs, which I can monitor with nvidia-smi. I don't see script.sh in "top" but I do see the program it keeps calling. I have been able to get around this by the following:
while true
do
sleep 1
pkill (the other program)
After a minute or so it kills all the iterations that script.sh would do. But this is not an elegant way to do it.
If I was physically at where the server is (I do go sometimes), I do the following in the same situation:
pkill -u (me)
This kills everything I'm doing. I just log back on and start over, no big deal. It happens a lot while I debug the other program. But right now I'm logged in via a command like this executed on the server:
ssh -r (server) (my home)
So if I do that, it will kill my connection to the server. Obviously I don't want to do that.
Normally I would be a bit more adventurous and try things before I run here to ask, but I am playing it safe. I don't want to kill my ssh connection. How can I properly kill script.sh elegantly? (Yes, I did try simply doing "pkill script.sh" or "kill script.sh", it did nothing).