Re: Cronjob and sudo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Thu, February 12, 2015 12:32 pm, Matt wrote:
> I need to remove empty files out of a directory that are over 6 hours
> old so I created this script and put it in cron.hourly.
>
> #!/bin/sh
> cd /var/list
> sudo -u matt find /var/list -mmin +360 -empty -user matt -exec rm {} \;
>
> I want to run it as matt rather than root for just an added bit of
> safety.  Problem is I get this.
>
> "sudo: sorry, you must have a tty to run sudo"
>
> Is there another way to do this?  As I understand the reason for this
> is requiretty in sudo config.  If that improves security I would
> rather not change that setting.

Did you try to use su instead? E.g., in my /etc/rc.local I have a bunch of
stuff run on behalf of users other than root. Like:

/bin/su lmgrd -c 'export
IDL_DIR=/usr/local/opt/flexlm/idl;/usr/local/opt/flexlm/idl/bin/lmgrd -c
/usr/local/opt/flexlm/licenses/license.dat -l /var/log/flexlm/idl.log >
/dev/null 2>&1'

Valeri

++++++++++++++++++++++++++++++++++++++++
Valeri Galtsev
Sr System Administrator
Department of Astronomy and Astrophysics
Kavli Institute for Cosmological Physics
University of Chicago
Phone: 773-702-4247
++++++++++++++++++++++++++++++++++++++++
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux