请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:AM5728 工具/软件:Linux
我在 C/C++中编译了一个可执行程序、并且希望在启动 Linux 系统时自动以根启动程序。但我发现登录操作是在自动启动程序之后进行的。如何在 root 帐户中自动设置程序启动。systemd mechnism 能否实现这一点?
感谢你的任何帮助。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具/软件:Linux
我在 C/C++中编译了一个可执行程序、并且希望在启动 Linux 系统时自动以根启动程序。但我发现登录操作是在自动启动程序之后进行的。如何在 root 帐户中自动设置程序启动。systemd mechnism 能否实现这一点?
感谢你的任何帮助。
user5032711、
我想补充一些澄清。
让您的可执行程序命名为"YourApp"。
例如,您应该在文件夹/etc/systemd/system 中创建 名为“testscript.service"”的服务。
[unit] Description=我的测试脚本 after = network.target [Service] ExecStart=/path_TO_YourApp/YourApp Type=OneShot StandardOutput=kmsg+console [安装] Wanteby=multi-user.target
然后执行以下命令:
systemctl 启用 testscript.service systemctl 守护程序重新加载
重新启动设备应执行 YourApp。
BR
Tsvetolin Shulev