我有一个问题,当我添加 '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
它非常有效。
那么,这是为什么?
最佳答案
每当使用 rc.local
你不能假设你的命令是自动识别的,因为 PATH
在某些情况下,变量尚未加载。
尝试运行二进制文件的完整路径,而不仅仅是名称。
您可以使用 which ssserver
找到二进制文件的完整路径。
从我所看到的shadowsocks.json
文件权限很好,因为所有用户都可以读取它,如果还需要写入,您可以运行 chmod a+w /etc/shadowsocks.json
如root
或使用 sudo
.
关于Ubuntu/etc/rc.local 没有 sudo 就无法运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31155501/