1. 云栖社区>
  2. PHP教程>
  3. 正文

sudo: sorry, you must have a tty to run sudo

作者:用户 来源:互联网 时间:2017-12-01 10:42:37

sudorunmustYouSorrytty

sudo: sorry, you must have a tty to run sudo - 摘要: 本文讲的是sudo: sorry, you must have a tty to run sudo, 通过 [[email protected] ~]$ crontab -ecrontab: installing new crontab[[email protected] ~]$ crontab -l10 11 11 4 * /home/


通过


[[email protected] ~]$ crontab -e
crontab: installing new crontab
[[email protected] ~]$ crontab -l
10 11 11 4 * /home/simonsun/Desktop/shutdown.sh


添加了一个自动关机的任务:


#!/bin/sh
sudo /sbin/shutdown -h now


但并没有成功,收到了系统的一封信:


[[email protected] ~]$ cat /var/spool/mail/simonsun
From [email protected] Sun Apr 11 11:10:02 2010
Return-Path: <[email protected]>
Received: from magic.linux (magic.linux [127.0.0.1])
        by magic.linux (8.13.8/8.13.8) with ESMTP id o3B3A1L7005990
        for <[email protected]>; Sun, 11 Apr 2010 11:10:02 +0800
Received: (from [email protected])
        by magic.linux (8.13.8/8.13.8/Submit) id o3B3A1LU005989;
        Sun, 11 Apr 2010 11:10:01 +0800
Date: Sun, 11 Apr 2010 11:10:01 +0800
Message-Id: <[email protected]>
From: [email protected] (Cron Daemon)
To: [email protected]
Subject: Cron <[email protected]> /home/simonsun/Desktop/shutdown.sh
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
sudo: sorry, you must have a tty to run sudo


 


随后查找资料,修改一下好了:注释掉 /etc/sudoers中 ‘Defaults requiretty
’。
[[email protected] ~]$ sudo visudo
[[email protected] ~]$


参考连接:


http://hi.baidu.com/powersaven/blog/item/605c7344f25a8a2dcefca3fd.html


http://www.question-defense.com/2009/03/23/sudo-sorry-you-must-have-a-tty-to-run-sudo


http://linux.chinaunix.net/bbs/viewthread.php?tid=901336


 


注:最好这样写: #crontab -e


10 11 11 4 * sh
/home/simonsun/Desktop/shutdown.sh


,否则系统有时候会报/bin permission denied.


 

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索sudo , run , must , You , Sorry tty ,以便于您获取更多的相关知识。