美文网首页
Linux systemd rc-local.service 实

Linux systemd rc-local.service 实

作者: 霡霂976447044 | 来源:发表于2022-01-06 16:27 被阅读0次

1 开启rc-local.service

vim /lib/systemd/system/rc-local.service

追加如下

[Install]
WantedBy=multi-user.target

使其在multi-user启动后能启动, 同时

systemctl enable rc-local.service

2 编写rc.local

rc-local.service会执行 /etc/rc.local 只需要创建这个文件即可

/etc/rc.local

#!/bin/bash
touch /tmp/`date "+%Y-%m-%d_%H:%M:%S"`.log

对于长时间执行的可以加上&试试,最后不要忘记添加可执行权限

sudo chmod +x /etc/rc.local

3 重启或执行service检验是否成功

systemctl start rc-local.service

相关文章

网友评论

      本文标题:Linux systemd rc-local.service 实

      本文链接:https://www.haomeiwen.com/subject/zxlrcrtx.html