假设我在 Linux CentOS 上转到此文件来设置一些启动命令
sudo vi /etc/rc.local
在这种情况下,假设我想启动 uwsgi
所以通常在命令行中我可能会输入如下内容:
[linuxuser@localhost ~]$ systemctl start uwsgi
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to start 'uwsgi.service'.
Multiple identities can be used for authentication:
1. admin Support (Administrator)
2. linuxuser (linuxuser)
Choose identity to authenticate as (1-2): 2
Password:
我如何将身份和密码放入 rc.local 文件中以便让 uwsgi 在启动时运行?
像这样的东西吗?
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
systemctl start uwsgi
2
mypassword1$
我认为这是不对的..
答案1
它想要进行身份验证,因为您不是 root。因此,从 rc.local 开始将像以 root 身份运行一样工作。但这不是正确的方法 - uwsgi 是一项服务,因此可以设置为在启动时启动:
sudo systemctl enable uwsgi.service