requiretty setting is enabled in almost every linux systems by defaults. Enable requiretty will cause cron, scripts or process do not get tty session.
If set, sudo will only run when the user is logged in to a real tty. When this flag is set, sudo can only be run from a login session and not via other means such as cron(8) or cgi-bin scripts. This flag is off by default.
Besides that, if you encounter error syntax like this:-
sudo: sorry, you must have a tty to run sudo
you can disable requiretty as well in sudoers using visudo.
Disable requiretty to particular user not to use tty.
In this file : /etc/sudoers
Change this
Defaults:username requiretty
for
Defaults:username !requiretty
https://linuxreference.wordpress.com/2010/11/22/disable-requiretty-in-etcsudoers/