If you ever get an error to disable requiretty, you simply need to comment #Defaults requiretty
line on the sudoers file.
→ sudo vim /etc/sudoers → Comment out requiretty #Defaults requiretty
After disabling requiretty you might need to allow user say (sam) and apache to use the command without prompting for password. For this add following line at the end of the /etc/sudoers
file
# Apache can check lsof as root for cron_localbatch.php apache ALL=NOPASSWD:/usr/sbin/lsof # used for deployment sam ALL=NOPASSWD:/bin/cp sam ALL=NOPASSWD:/bin/chmod sam ALL=NOPASSWD:/bin/chown
Hope this Helps!