Script to kill some processes

I could use a script to kill some processes.

I mainly have the following open:

Firefox, Thunar, Geany,

I think killall is what I need.

1 Like

Do you want to kill

  • all non-OS?       or
  • all non-session User-specific?       or
  • all, namely, kill the system?

I do not want to kill my system.

What is all non-OS?

Assuming only one User session, either all children of your open Mate session (first 2 commands below), or all children of each identified terminal session (3rd command below):

I forgot one view: Applications Launched from Panel "button":

For that last one, give this a try (selective killing):

#!/bin/sh

if [ "$1" = "--debug" ] ; then  debug=1 ; else  debug=0 ; fi

me=$(whoami | cut -c1-7 )

panelPID=$(ps -ef | awk '{ if( $8 == "mate-panel" ){ print $2 ; } ; }' )

test ${debug} -eq 1 && echo ${panelPID}

ps -ef | grep -v 'mate-terminal' |
	awk -v ppid="${panelPID}" -v user="${me}" '{ if( $3 == ppid && $1 ~ user ){ print $0 ; } ; }' |
	while read line
	do
		if [ -z "${line}" ]
		then
			exit
		fi
		pid=$(echo "${line}" | awk '{ print $2 }' )
		name=$(echo "${line}" | awk '{ n=split( $8, path, "/" ) ; print path[n] ; }' )
		echo "\t Process:"
		echo "\t   reported:      ${line}"
		echo "\t   application:   ${name} [${pid}]"
		echo "\t   Kill ? [y|N] => \c" ; read ans <&2
		test -z "${ans}" && ans="N"
		case "${ans}" in
			y* | Y* )	
				kill -s HUP ${pid}
				test $? -eq 0 && { echo "\t\t\t Terminated with HUP signal ..." ;
				} || {
					kill -s INT ${pid} ;
					test $? -eq 0 && { echo "\t\t\t Terminated with INT signal ..." ;
					} || {
						kill -s KILL ${pid} ;
						test $? -eq 0 && { echo "\t\t\t Terminated with KILL signal ..." ;
						} ;
					} ;
				}
				;;
			* ) echo "\t\t Ignoring process for '${name}' ..." ;;
		esac
	done