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:-