1

I wanted to do a test for the Job Control Commands.

So, I ran a cat command and then made it a background job using the bgcommand after stopping it with Ctrl +Z.

Now I wanted to first terminate that background process, so I used the command %kill-2%2 as the Process ID was [2] but it gave me an error saying "No such job". I tried it will %kill-9%2 but same error.

I checked it with fg command and that job was still running and it came on foreground

Similarly, I wanted to suspend a background job, so I used the command %kill-19%2 but it gave me an error that "No such Job"

I would like to know my fault or error.

  • 2
    It's unclear what you're actually typing which is why I hesitate in providing a direct answer. Did you type kill -2 %2 (with proper spacing and no beginning %)? – Julie Pelletier Jun 25 '16 at 1:57
  • No @JuliePelletier I typed %kill-2%2 without any space because if I give a space then it gives me an error "Too many arguments" – Anonymous Jun 25 '16 at 2:00
  • Then go ahead and try it as I said: kill -2 %2. If that doesn't work, show us the exact command and error message. – Julie Pelletier Jun 25 '16 at 2:09
  • Yeah, It is working. Thanks a lot. I have a question that why some websites say to use % sign before that "kill" word ? – Anonymous Jun 25 '16 at 2:23
  • Many shell command examples show the prompt before the command, but of course you're not supposed to type the prompt😃 – Hans-Martin Mosner Jun 25 '16 at 5:25
1

The command should be kill -2 %2 with proper spacing.

The % sign at the beginning of your line is probably just the prompt they are using (PS1).

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.