Ubuntu: Kill all instances of a service


I managed to create a systemd service script, which enables my application to run in the background...
This systemdscript used %i in order to start specific instances of this service.
I'm searching for a way to stop all instances of my script.
sudo service servicename@* stop isn't working...
ExecStart runs a script which runs a java application

Any help is appreciated


The command you are looking for is:

sudo killall nameofservice  

You can use tab to autocomplete.


You better use

sudo killall -9 nameofservice  

Of course you need to know the name of the service which is not necessarily equal to its init.d script name.

The parameter -9 of the killall command is explained in the manual page

man 7 signal  

Just enter it at the command line to get:

First the signals described in the original POSIX.1-1990 standard.       Signal     Value     Action   Comment     â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€â"€     SIGHUP        1       Term    Hangup detected on controlling terminal                                   or death of controlling process     SIGINT        2       Term    Interrupt from keyboard     SIGQUIT       3       Core    Quit from keyboard     SIGILL        4       Core    Illegal Instruction     SIGABRT       6       Core    Abort signal from abort(3)     SIGFPE        8       Core    Floating point exception     SIGKILL       9       Term    Kill signal     SIGSEGV      11       Core    Invalid memory reference     SIGPIPE      13       Term    Broken pipe: write to pipe with no                                   readers     SIGALRM      14       Term    Timer signal from alarm(2)     SIGTERM      15       Term    Termination signal     SIGUSR1   30,10,16    Term    User-defined signal 1     SIGUSR2   31,12,17    Term    User-defined signal 2     SIGCHLD   20,17,18    Ign     Child stopped or terminated       SIGCONT   19,18,25    Cont    Continue if stopped     SIGSTOP   17,19,23    Stop    Stop process     SIGTSTP   18,20,24    Stop    Stop typed at terminal     SIGTTIN   21,21,26    Stop    Terminal input for background process     SIGTTOU   22,22,27    Stop    Terminal output for background process       The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.  


Thanks for all your suggestions, but I found an answer here: https://serverfault.com/a/797926
The problem was, that my asterisk was escaped by bash...
When using sudo service 'servicename@*' stop everything works as expected

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »