gpt4 book ai didi

linux - 脚本在 raspbian 中运行两次

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

我是 Raspberry Pi 的新手,我想在 Pi 启动后自动运行一个程序。当我尝试运行 ./myscript.sh 时,我的脚本工作正常。由于每次 Pi 启动时都需要运行,我在上面提到了 /etc/rc.local 中的脚本路径为 /home/pi/myscript.sh 退出 0

一旦我重新启动 Pi,我就可以看到来 self 的脚本的日志消息等等,但是当我试图查看进程 ID 时,我发现该应用程序有两个进程,我开始使用该脚本。

root     607    1    11:30  ?     00:00:00  /bin/sh -e /etc/rc.local start
root 615 607 11:30 ? 00:00:00 /bin/bash /home/pi/myscript.sh
root 684 615 11:30 ? 00:00:00 sudo ./rte -bf runappl.xml
root 689 684 11:30 ? 00:00:00 ./rte -bf runappl.xml

myscript.sh 看起来像

#!/bin/bash
echo " Configuring eth0 multicast ... "
sudo ifconfig eth0 multicast
sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0

export rte_bin_dir="../home/pi/rte/bin/"
if [ -d "$rte_bin_dir" ]; then
cd "./$rte_bin_dir"
sudo ./rte -bf runappl.xml
else
echo "unable to locate ${rte_bin_dir}"
exit 1
fi

这是预期的正确结果还是我假设出了什么问题?

有没有办法在我看到桌面(主屏幕)后自动运行脚本

最佳答案

这是正常的,因为您正在执行命令。一个进程 (684) 用于切换用户部分(此处为 sudo),另一个进程 (689) 用于程序本身。

所以没关系,你的程序没有运行两次。

关于linux - 脚本在 raspbian 中运行两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38750017/

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