我有一个问题,当我添加'ssserver -c /etc/shadowsocks.json -d start'on /etc/rc.local时,它看起来像这样:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
ssserver -c /etc/shadowsocks.json -d start
exit 0
重新启动计算机时无效。 但是当我在“ssserver -c /etc/shadowsocks.json -d start”之前添加sudo时,
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo ssserver -c /etc/shadowsocks.json -d start
exit 0
它非常有效。 那么,这就是为什么?
答案 0 :(得分:0)
ssserver需要sudo
个权限。
ll /etc/shadowsocks.json
-rw-r - r-- 1 root root 151 Dec 15 20:40 /etc/shadowsocks.json
答案 1 :(得分:0)
每当使用rc.local
时,您都不能认为您的命令是自动识别的,因为在某些情况下尚未加载PATH
变量。
尝试运行二进制文件的完整路径,而不仅仅是名称
您可以使用which ssserver
从我看到的shadowsocks.json
文件权限很好,因为所有用户都可以阅读它,如果还需要写入,您可以chmod a+w /etc/shadowsocks.json
运行root
或使用{ {1}}。