【发布时间】:2015-07-02 13:55:22
【问题描述】:
sudo: no tty present and no askpass program specified
您好,当我尝试运行以下 crontab 时,我遇到了上述错误。
*/5 * * * * sudo bash /home/admin/scripts/monitor.sh /dev/null 2>&1
我使用 nano 作为编辑器来编辑管理员用户 crontab - 注意这不是 root 用户。
EDITOR=nano crontab -e -u 管理员
【问题讨论】:
-
为什么这个脚本需要 sudo?您每次都必须提供密码或更改 /etc/sudoers
-
@AndreySabitov 我是否更改此行#Defaults requiretty
-
monitor.sh 脚本以 #! /bin/bash?
-
我让它工作,通过将它移动到 root 用户运行