Linux系统下用systemd设置开机自动启动

不知道为什么有时后用rc.local设置启动项会失败,所以用systemd来设置开机自动启动

首先在/etc/systemd/system/目录下建一个文件
例如:

vi /etc/systemd/system/aaa.service

写入一下内容:

[Unit]

Description = This will run at startup


[Service]

ExecStart = /usr/bin/aaa.sh
#这里写要启动的程序,要有执行权限


[Install]

WantedBy = multi-user.target

使其生效

chmod +x /etc/systemd/system/aaa.service
systemctl enable /etc/systemd/system/aaa.service

猜你喜欢

转载自blog.csdn.net/weixin_43880667/article/details/86562901
今日推荐