-3

I have run a script like this:

script.sh > terminal.txt 2>&1 &

It contains long loops.

how can I trace (which process with what name and what id was created) that script and kill the process to terminate that?

tod
  • 1,539
  • 4
  • 17
  • 43
  • Possible duplicate of [How to debug a bash script?](http://stackoverflow.com/questions/951336/how-to-debug-a-bash-script) – sashoalm Mar 25 '16 at 10:34
  • I was responding to "how can I trace that script". – sashoalm Mar 25 '16 at 11:01
  • But doesn't `bash -x` from the question I linked help? I assume it would give you the info, what's started. I don't know about the PIDs though. – sashoalm Mar 25 '16 at 11:05
  • OK, glad you solved your problem, but word of advice for the future - many-**standalone**-questions-in-one post are forbidden, and mods are encouraged to pick one question at random, and delete the rest. You can then post the deleted parts as new questions. See https://meta.stackoverflow.com/questions/275908/more-than-one-question-per-post. When you have several **standalone** questions, take the time to make a separate post for each one. – sashoalm Mar 25 '16 at 11:14

2 Answers2

0

Type fg in the terminal. Then type Ctrl+c.

See: Job Control Commands

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
  • I have seen a number like this: `[1] 25647` but how to kill it. I have already used `pkill -f 25647` and its still running – tod Mar 24 '16 at 18:20
  • also Ctrl+c is not giving any response – tod Mar 24 '16 at 18:21
  • `pkill` takes a process *name* as argument, not a pid. Use `kill -9 25647` in that case. If you are in the same shell where you started the process you can also issue `kill -9 %1`. Bash will translate `%1` to the corresponding pid. – hek2mgl Mar 24 '16 at 18:27
0

Though, @hek2mgl 's answer was great help and paved the way to solution, but the actual solution is a bit different:

Type fg in the terminal.

Then type Ctrl+z.

tod
  • 1,539
  • 4
  • 17
  • 43