![]() | 1 akiakiseofficial 2018-12-03 19:30:32 +08:00 via iPhone 这....楼下教吧 |
![]() | 2 trait 2018-12-03 19:30:35 +08:00 via iPhone systemd ? |
4 jhytxy OP |
![]() | 5 hjc4869 2018-12-03 19:33:19 +08:00 sudo apt install initscripts |
6 trys1 2018-12-03 19:36:18 +08:00 via Android ![]() 请用 systemctl |
![]() | 7 Sorry 查错了。无视 #5 Debian 的 systemd 有 rc-local.service,应该放一个 /etc/rc.local 之后就能用? |
8 jhytxy OP @hjc4869 systemctl status rc-local.service ● rc-local.service - /etc/rc.local Loaded: loaded (/etc/systemd/system/rc-local.service; enabled) Active: failed (Result: exit-code) since Mon 2018-12-03 06:30:51 EST; 16min ago Process: 223 ExecStart=/etc/rc.local start (code=exited, status=127) Dec 03 06:30:51 107-172-77-132-host systemd[1]: Starting /etc/rc.local... Dec 03 06:30:51 107-172-77-132-host systemd[1]: rc-local.service: control pr...7 Dec 03 06:30:51 107-172-77-132-host systemd[1]: Failed to start /etc/rc.local. Dec 03 06:30:51 107-172-77-132-host systemd[1]: Unit rc-local.service entere.... Hint: Some lines were ellipsized, use -l to show in full. |
![]() | 9 ooh 2018-12-03 19:56:42 +08:00 |
11 dot2017 2018-12-03 20:02:01 +08:00 做成 service |
12 WordTian 2018-12-03 20:06:15 +08:00 via Android ![]() systemctl enable rc-local #设置 rc-local 开机启动 systemctl start rc-local #启动 rc-local 然后在 /etc/rc.local 文件中加命令就完了 |
13 jhytxy OP 笑话我的人有试过吗 每次都是 rc.local 打不开 我用 root 登录的 rc.local 里就一条 node /c9sdk/server.js -w ~/c9sdk/ -l 0.0.0.0 -a |
15 jhytxy OP @ooh cat /usr/lib/systemd/system/rc.local.service cat: /usr/lib/systemd/system/rc.local.service: No such file or directory |
17 jhytxy OP 踩了个大坑 国产教程里的 /usr/lib/systemd/system 是不存在于 debian 9 的 debian 9 在 /etc/systemd/system 里 |
![]() | 18 ooh 2018-12-03 20:55:47 +08:00 hulk@test:~$ cat /lib/systemd/system/rc.local.service # SPDX-License-Identifier: LGPL-2.1+ # # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # This unit gets pulled automatically into multi-user.target by # systemd-rc-local-generator if /etc/rc.local is executable. [Unit] Description=/etc/rc.local Compatibility Documentation=man:systemd-rc-local-generator(8) COnditionFileIsExecutable=/etc/rc.local After=network.target [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 RemainAfterExit=yes GuessMainPID=no [Install] WantedBy=multi-user.target hulk@test:~$ cat /etc/rc.local #!/bin/bash sleep 10 && mount -t vboxsf workspace /srv exit 0 hulk@test:~$ sudo systemctl status rc-local ● rc-local.service - /etc/rc.local Compatibility Loaded: loaded (/lib/systemd/system/rc-local.service; enabled; vendor preset: enabled) Drop-In: /lib/systemd/system/rc-local.service.d └─debian.conf Active: active (exited) since Mon 2018-12-03 12:40:38 UTC; 16min ago Docs: man:systemd-rc-local-generator(8) Process: 1001 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS) Dec 03 12:40:28 test systemd[1]: Starting /etc/rc.local Compatibility... Dec 03 12:40:38 test systemd[1]: Started /etc/rc.local Compatibility. |
![]() | 21 lemonda 2018-12-03 21:33:14 +08:00 你想开机运行 Cloud9 吧 我本来想看下自己是怎么设置开机启动的然后告诉你,结果发现一直是手动运行的 |
![]() | 22 zhucegeqiu 2018-12-03 22:05:11 +08:00 via iPhone Centos7 一样,用 systemd 吧,rc.local 不推荐使用了 |
![]() | 23 benjix 2018-12-03 22:42:46 +08:00 确保你的 rc.local 文件没问题 vim /lib/systemd/system/rc.local.service 在最后添加 [Install] WantedBy=multi-user.target 然后执行 systemctl daemon-reload systemctl enable rc.local systemctl start rc.local 重启试试 |
24 hcymk2 2018-12-03 22:48:00 +08:00 又不发开机日志,又不发代码。 |
![]() | 25 caola 2018-12-03 22:56:17 +08:00 systemd |
![]() | 26 FindHao 2018-12-03 23:42:25 +08:00 via Android systemd 很舒服,可以看看阮一峰的教程 |
![]() | 27 wwqgtxx  2018-12-04 00:13:56 +08:00 via iPhone ![]() 这个 service 文件一分钟就搞定的事,非要瞎折腾 |
![]() | 28 msg7086 2018-12-04 00:43:58 +08:00 都 8012 年了还在用着上古的不知道淘汰了多少年的 rc.local …… ermmm |
29 0ZXYDDu796nVCFxq 2018-12-04 01:27:10 +08:00 via Android rc.local 早该淘汰了 Systemd is No.1 |
![]() | 31 sagaxu 2018-12-04 02:06:21 +08:00 via Android ![]() 自带的 rc.local 缺了个 wantedby,所以即使做了 enable,重启后也是不会执行的,自己加一个就好了 |
![]() | 32 designer 2018-12-04 05:41:13 +08:00 via iPhone 不要轻易判断一个 OS 是不是恶心。就算不顺手可以选择不用 |
33 trafficMGR 2018-12-04 07:38:53 +08:00 via Android 所以这个问题跟 Debian 有什么关系吗 |
![]() | 34 silvernoo 2018-12-04 07:54:19 +08:00 via Android 我已经离不开 systemd 了 |
36 Sharuru 2018-12-04 08:09:20 +08:00 via Android 你 V 是这样的,越菜的越觉得这恶心,那恶心的,噗哧。 |
![]() | 37 fstab 2018-12-04 08:24:03 +08:00 via Android 从学用 linux,vps 一直都用 debian,直到现在大概有几年了,没遇到过什么坑。 |
38 scorn 2018-12-04 08:37:51 +08:00 via Android 我自己建一个 rc.local 解决 |
39 xuanaux 2018-12-04 22:03:30 +08:00 我用的是 Ubuntu,当初直接创建 rc.local 文件并富裕执行权限就可以正常使用,你看看是不是日常.local 哪里写错了。 最后问下 systemd 有类似于 rc.local 这种方便的功能么?总不能每个命令写一个 Server 文件吧。 |
![]() | 40 wwqgtxx 2018-12-05 11:26:40 +08:00 ![]() @xuanaux systemd 的逻辑就是每个服务写一个 service 文件,这种东西写多了就是每次 cp 一份改一下名字,描述,命令,熟练了之后都能闭着眼睛敲出来了。 好处是你可以很方便的管理你启动的每个命令,systemctl start\stop\status xxx.service 即可。 至于想要实现 rc.local 的功能,你自己创建个 service 把 ExecStart 指向一个 shell 脚本不就得了,只不过注意 service 文件中的 type,具体的可以参见 http://www.jinbuguo.com/systemd/systemd.service.html |