当PC重新启动时,我们需要将Apache2服务器和xsp2服务器(或mono服务器)合并到下面所示的自动启动示例的配置中。
引用这篇文章,https://askubuntu.com/questions/9382/how-can-i-configure-a-service-to-run-at-startup
"sudo update-rc.d minidlna defaults
This should add the service to the automatic startup system. But if you get:
System start/stop links for /etc/init.d/minidlna already exist.
Do the command
sudo update-rc.d minidlna enable"如何调整上述示例,以便在自动启动过程中将Apache2服务器和xsp2服务器合并在一起?
我想先启动Apache2,然后再启动xsp2 next。这是否可能与Ubuntu16.04有关,还是有更好的方法?
任何帮助都是非常感谢的。
发布于 2016-06-13 01:22:36
我要感谢@garethTheRed建议使用systemd而不是update-rc.d。
URL 编写基本的系统服务文件包含这个答案。
步骤1:我创建了这个文件(备注位置),它实际上是用一个扩展的参数触发bash进程。您可以发射自己的命令,这可能与bash不同。
[root@y500-fedora ~]# cat /usr/lib/systemd/system/foo.service
[Unit]
Description=foo
[Service]
ExecStart=/bin/bash -c "while true; do /bin/inotifywait -qq --event close_write /sys/class/backlight/acpi_video0/brightness; su myusername -c '/bin/xbacklight -display :0 -set $(cat /sys/class/backlight/acpi_video0/brightness)'; done"
[Install]
WantedBy=graphical.target
Step 2:
systemctl enable foo
(similarly you can disable it)(可选)步骤3:它应该在下一次重新启动时自动启动到图形模式(运行级别5),但是如果您想立即启动它:
# systemctl start foo
# systemctl status foo # optional, just to verifyhttps://unix.stackexchange.com/questions/289331
复制相似问题