On Mon, 19 Oct 2015, rhubarbpieguy at gmail.com wrote:

> On 10/17/2015 09:52 AM, rhubarbpieguy at gmail.com wrote:
>> 
>> I'm unable to kill Script2Kill.sh using "pkill Script."  Using jobs I see:
>>
>>    [1]+  Running            ./Script2Kill.sh &
>> 
>> I can kill the script with "kill %1" but "pkill Script" has no effect. 
>> I've tried several combinations, but if I understand correctly, pkill 
>> and part of the name string should work.  Can others use pkill 
>> successfully?
>
> The responses correctly point to the problem.  I'm interested in killing 
> the script by name.  I can get the script name with the jobs command as 
> I run it in the background.  However, I apparently can't kill a script 
> running in the background by name; only a process by name.
>
> It's not difficult to find the script(s) by name and then kill them with 
> a script.  I hoped for some obscure command to so, but worse things have 
> happened.


What am I doing differently from you?  Here I make a script, execute it, 
then kill it using pkill, which works:


$ cat > nonsensical.bash
#!/bin/bash

for I in {1..100} ; do echo "a" > /dev/null ; sleep 10 ; done
^D

$ chmod 755 nonsensical.bash

$ ./nonsensical.bash &
[6] 12253

$ pkill nonsensical
[6]-  Terminated              ./nonsensical.bash


Best,
Mike