1827433 Members
4922 Online
109965 Solutions
New Discussion

Re: kill

 
SOLVED
Go to solution
Nobody's Hero
Valued Contributor

kill

Any idea how I can allow a user to kill only sendmail processes using sudo?
I installed sudo but dont want to give him the access to kill any root process. Only sendmail.
UNIX IS GOOD
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor
Solution

Re: kill

Hi:

Use 'sbin/init.d/sendmail stop' or use 'killsm'. See the manpages for 'killsm(1M)'.

Regards!

...JRF...
F Verschuren
Esteemed Contributor

Re: kill

if it is only for the hanging jops and not sendmail it self:
#!/bin/ksh
ps -ef |grep sendmail |grep -v "accepting"| awk '{ print $2 } ' |while read line
do
sudo kill $line
done
asuming you sendmail deamon runs as:
root 1092 1 0 10:29:52 ? 0:00 sendmail: accepting connections

Hasan  Atasoy
Honored Contributor

Re: kill

wriet a script like


#!/bin/sh

kill -9 `ps -ef | grep sendmail | grep -v grep`

and use sudo for this script.

Hasan.
Hasan  Atasoy
Honored Contributor

Re: kill

wriet a script like


#!/bin/sh

kill -9 `ps -ef | grep sendmail | grep -v grep | awk '{print $2}'`

and use sudo for this script.

Hasan.
Sandman!
Honored Contributor

Re: kill

How about giving a user the ability to run sendmail as root? See "Runas_Spec" parm in the /etc/sudoers file viz.,

= (root) /usr/sbin/sendmail

the above would give the named user the ability to run sendmail as superuser.
Geoff Wild
Honored Contributor

Re: kill

Better yet - don't run sendmail as root!

http://docs.hp.com/en/B2355-91064/ch02s07.html

And others...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Geoff Wild
Honored Contributor

Re: kill

BTW - it is a bad idea to kill -9 the sendmail daemon pid.....

Just my 2 cents (and I'm pretty sure others)....Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Sandman!
Honored Contributor

Re: kill

I like JRF's suggestion since the kill "-k" command line option to sendmail has been deprecated. Earlier one could "sendmail -bk" to kill the daemon process which has now been replaced by killsm i.e.

= (root) /usr/sbin/killsm