gpt4 book ai didi

linux - 以 root 身份从 linux bash 重启 apache2

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:01:32 24 4
gpt4 key购买 nike

我想在 linux (OpenSUSE) 中从 bash 重启 apache。

我正在尝试从文件 (stdin) 中读取根密码。我是这样做的:

exec < /opt/otrsadm/stdin
read a1
sudo apache2ctl -k graceful
echo $a1

我在我的日志中得到了这个:

[Mon Sep 12 23:23:12 2011] [error] [client 192.168.1.101] Restarting apache
[Mon Sep 12 23:23:13 2011] [error] [client 192.168.1.101] sudo
[Mon Sep 12 23:23:13 2011] [error] [client 192.168.1.101] :
[Mon Sep 12 23:23:13 2011] [error] [client 192.168.1.101] no tty present and no askpass program specified

我的问题是什么,我该如何解决?

最佳答案

sudo -S 选项从标准输入读取密码。

The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.

echo "password" | sudo -S apache2ctl -l graceful 

关于linux - 以 root 身份从 linux bash 重启 apache2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7394264/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com