i have problem with linux (ubuntu 16.04) permissions and command execution.
/etc/sudoers file:
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
root ALL=(ALL:ALL) ALL
%admin ALL=(ALL) ALL
%sudo ALL=(ALL:ALL) ALL
#includedir /etc/sudoers.d (this dir is empty)
jenkins ALL=(deployer) NOPASSWD: ALL
deployer ALL=NOPASSWD:/etc/init.d/php7.0-fpm reload,/bin/kill,/bin/ps,/bin/grep,/usr/bin/awk,/usr/bin/xargs
I need to run this command, i am looged as user jenkins:
sudo -u deployer kill -9 $(ps aux | grep /data/web/test1 | grep -v grep | awk {'print $2'})
This command has to kill 2 processes. But when i run it like this, i get exit status 1. I dont know why and i cant find any logged error messages ...
When i log in as deployer user and run this command, everything is ok:
kill -9 $(ps aux | grep /data/web/test1 | grep -v grep | awk {'print $2'})
Processes i need to kill looks like:
www-data 48689 0.0 1.6 306184 33872 ? Ss 14:26 0:00 /usr/bin/php /data/web/test1/xxx
www-data 48690 0.0 1.6 306184 34108 ? Ss 14:26 0:00 /usr/bin/php /data/web/test1/yyy
I find out that problem is only with kill command but i really dont know why.