树莓派 3 型号 b 中的 Rc.local

树莓派 3 型号 b 中的 Rc.local

我正在开发 raspberry pi 3 model b arm 版本,运行 Debian 我需要在启动时运行一个脚本,我正在使用 /etc./Rc.local 执行此操作我遵循了这本食谱:https://www.cyberciti.biz/faq/how-to-enable-rc-local-shell-script-on-systemd-while-booting-linux-system/ 一切工作正常,有一些回显日志我发送到 log.txt 文件,我看到命令正在执行,但当我尝试运行脚本时,我确实需要它不起作用,Rc 中的所有其他命令.local 文件正在执行,但没有对我来说最重要的文件。

/etc/rc.local 文件:

> ##Reload deamon
 sudo systemctl daemon-reload && echo "Daemon -> SUCCESS" >> /tmp/mounter_test.txt || echo "Daemon -> FAIL" >>
> /tmp/mounter_test.txt
> ##Checking which user is running
> whoami >> /tmp/mounter_test.txt
> ##Check log
> echo "First try" >> /tmp/mounter_test.txt
> enc /opt&
> 
> if [ $? -eq 0 ]; then
>         echo "The mounter is running" >> /tmp/mounter_test.txt else
>         echo "The mounter has failed!!" >> /tmp/mounter_test.txt fi
> 
> exit 0

猫/tmp/enc_test.txt

SUCCESS
root
First try
The mounter is running

systemctl staus rc-local.service ----启动后----

● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: enabled)
  Drop-In: /usr/lib/systemd/system/rc-local.service.d
           └─debian.conf
           /etc/systemd/system/rc-local.service.d
           └─ttyoutput.conf
   Active: active (exited) since Tue 2022-05-17 09:37:56 BST; 2min 27s ago
     Docs: man:systemd-rc-local-generator(8)
  Process: 477 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

May 17 09:37:55 raspberrypi systemd[1]: Starting /etc/rc.local Compatibility...
May 17 09:37:55 raspberrypi sudo[480]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/systemctl daemon-reload
May 17 09:37:55 raspberrypi sudo[480]: pam_unix(sudo:session): session opened for user root by (uid=0)
May 17 09:37:56 raspberrypi sudo[480]: pam_unix(sudo:session): session closed for user root
May 17 09:37:56 raspberrypi systemd[1]: Started /etc/rc.local Compatibility.

更重要的一件事是,如果我在终端中运行 /etc/rc.local,则加密正在工作,因此只有此命令和 rc.local 中的命令。

非常感谢您的帮助!谢谢你们 :)

相关内容