I can run the following shell script from command prompt as expected:
/bin/sh -xv /home/shantanu/backup_transfer.sh
But when I set it in a cron, it does not execute correctly. There are 2 commands. ssh -t abc@10.10.10.100 "sudo ls" and sudo rsync -avze to another server.
Why would a shell script fail in a cron when it runs successfully at command prompt?
$ which sh
/bin/sh
Am I using the correct environment?
Update:
Error for the first ssh -t command:
Pseudo-terminal will not be allocated because stdin is not a terminal.
sudo: sorry, you must have a tty to run sudo
Error for the second sudo rsync command:
sudo: sorry, you must have a tty to run sudo
No error while running the script at command prompt.
sudo? Did you configure with passwordless? – quanta Nov 21 '11 at 3:07command >> /tmp/log 2>&1– quanta Nov 21 '11 at 3:29-tor edit your/etc/sudoersfile with something like thisDefaults:abc !requiretty. Why didn't you search the above error in this site? – quanta Nov 21 '11 at 3:52