简体   繁体   English

Linux使用/etc/init.d/中的脚本自动启动

[英]Linux autostart with script in /etc/init.d/

I have some trouble with starting my written C++ application each time my raspberry pi with raspbian OS boots. 每当我用raspbian OS引导树莓派时,启动我编写的C ++应用程序都会遇到麻烦。 I found the following instructions: 我发现以下指示:

http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html

So I followed all of the mentioned steps: 因此,我遵循了所有上述步骤:

  1. Created my script in /etc/init.d/myScript (by copying and modifying an existing one) 在/etc/init.d/myScript中创建了我的脚本(通过复制和修改现有脚本)
  2. Entered the path to my C++-Programm: 输入我的C ++程序的路径:

case "$1" in 案例“ $ 1”在
start) 开始)

echo "Starting my programm..." 回声“正在启动程序...”

/home/pi/myProgram ;; / home / pi / myProgram ;;

Note: In reality this file is well formatted and I dont get a parsing error! 注意:实际上,此文件格式正确,我没有解析错误! However if I want to start my own service with 但是,如果我想以以下方式启动我自己的服务:

sudo service myScript start

i get the following message: 我收到以下消息:

/home/pi/myProgram    no such process

Seems to me that my C++ program can not be found? 在我看来找不到我的C ++程序? What should I do? 我该怎么办?

"no such process" is almost certainly the output of the "killall" command, which would be invoked when you call "service myScript stop". 几乎可以肯定,“ no such process”是“ killall”命令的输出,当您调用“ service myScript stop”时将调用该命令。 I think you should double-check the init script that you copied and altered; 我认为您应该仔细检查您复制和更改的init脚本; it looks like the syntax for the case...esac got mangled. 看起来像是这种情况的语法... esac被弄乱了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM