![启动脚本在启动时不执行](https://linux22.com/image/835588/%E5%90%AF%E5%8A%A8%E8%84%9A%E6%9C%AC%E5%9C%A8%E5%90%AF%E5%8A%A8%E6%97%B6%E4%B8%8D%E6%89%A7%E8%A1%8C.png)
我已经按照教程这里显示如何设置 No-ip 更新程序以在系统启动时启动。
我完全按照此处所述操作,但程序仍然无法启动。此外,当我使用sudo service noip2 start
服务“noip2”时,它无法被识别。
我如何才能获取任意脚本并将其设置为在启动时执行。我尝试了许多有关 upstarts 等的教程,但都不起作用。谢谢。
> 1. Execute the following commands at the Terminal sudo chmod 700 /usr/local/bin/noip2 chown root:root /usr/local/bin/noip2
>
> 2. Now create a shell script called “noip2.sh” in the directory /etc/init.d
> #! /bin/sh
> # /etc/init.d/noip2.sh
>
> # Supplied by no-ip.com
> # Modified for Debian GNU/Linux by Eivind L. Rygge
> # corrected 1-17-2004 by Alex Docauer
>
> # . /etc/rc.d/init.d/functions # uncomment/modify for your killproc
>
> DAEMON=/usr/local/bin/noip2 NAME=noip2
>
> test -x $DAEMON || exit 0
>
> case “$1″ in start) echo -n “Starting dynamic address update: “
> start-stop-daemon –start –exec $DAEMON echo “noip2.” ;; stop) echo -n
> “Shutting down dynamic address update:” start-stop-daemon –stop
> –oknodo –retry 30 –exec $DAEMON echo “noip2.” ;;
>
> restart) echo -n “Restarting dynamic address update: “
> start-stop-daemon –stop –oknodo –retry 30 –exec $DAEMON
> start-stop-daemon –start –exec $DAEMON echo “noip2.” ;;
>
> *) echo “Usage: $0 {start|stop|restart}” exit 1 esac exit 0
>
> 3. Now finally execute this command in Terminal: sudo update-rc.d noip2.sh defaults 90
答案1
在 Ubuntu 中,最简单的方法可能就是使用启动应用程序工具。将脚本放入需要的位置,然后指定其完整路径(例如,/home/conor/script.sh)。
希望在启动时运行该脚本。我每次登录时都会使用它来启动我的 Thunderbird。