I have passwordless access to a server. My user account has added in sudoers file for NOPASSWD usage for some services/daemons in /etc/init.d/.
I want to write a script to start or stop a daemon according to some test results. I had set a cron to run this script at a specific time. But it returns error "sudo: no tty present and no askpass program specified".
I can use the " sudo /etc/init.d/service name start/stop without password in terminal.I do not have root password.
I have double checked /etc/sudoers file. There is no "requiretty". I am using Ubuntu-10.04 , 2.6.32-24-generic.
Following are the active lines in sudoers:
Defaults env_reset
root ALL=(ALL) ALL
bijo ALL=NOPASSWD: /etc/init.d/apache2
%sudo ALL=(ALL) ALL
%admin ALL=(ALL) ALL