跳转到主要内容

如何为Intel Edison 设置开机自动运行程序,systemd 设置篇

kelly 提交于


因为 Edison yocto 引入了 systemd 作为它的服务管理系统,所以如果想在其下启用服务(开机自动运行的程序,下同)应该使用 systemd 而非 init.d。这篇文章教你如何写简单的 service 脚本,如何并把你的程序设置成自动开机运行 :)。

我们先假设你的程序是放在 /home/root/programs 目录下,名字叫 myapp,并且已经设置好执行权限。

接下来运行 cat 新建 service 脚本文件

# cat /lib/systemd/system/mystartupapp.service

[Unit]

Description=My startup app

After=network.target

[Service]

#User=root

ExecStart=/home/root/programs/myapp

Restart=always

RestartSec=10s

[Install]

WantedBy=multi-user.target

在命令行中敲入

#systemctl enable mystartupapp

这里的 mystartupapp 与 service 的名字相同即可

然后重启 Edison

#reboot

看看效果吧:)

文章来源:Gekius