Wednesday, April 11, 2012

sudo: Sorry, you must have a tty to run sudo (SOLVED)

I found that running a cron job on CentOS I am getting an error:
sudo: Sorry, you must have a tty to run sudo
the script, running not as a root user was using a sudo command.

Some googling showed that this is what I need (run sudo visudo to edit the config file):
Defaults requiretty
Defaults:root !requiretty
Defaults:myusername !requiretty


Thus the default remains "requiretty" for everyone but for the named users.