I am trying to kill a process by his name in a script.
Process :
toto 15408 1 0 Nov13 ? 00:20:36 java -Xmx512m -XX:MaxPermSize=128m -cp /local/toto//conf/:/local/toto//lib/* com.toto.main.entry.Launchtoto processToto
in my script :
/usr/bin/sudo -u toto /usr/bin/pkill -9 -f $pname
In sudoers :
script_user server1=(toto) NOPASSWD: /usr/bin/pkill -9 -f java *
It doesn't work. Either I have a sudo error (sudo: no tty present and no askpass program specified
) or a pkill error (/usr/bin/pkill: invalid option -- 'X'
).
pname
contains:
java -Xmx512m -XX:MaxPermSize=128m -cp /local/toto//conf/:/local/toto//lib/* com.toto.main.entry.Launchtoto processToto
pname
set to? Please add the exact command you're running and the exact output to your question. To get the command being run, putset -x
in the line aboutpkill
in your script. – Mikel Nov 19 '15 at 16:54