rc-local 服务
Tofloor
poster avatar
yunaaaaa
deepin
2020-12-26 01:15
Author

本人写了一个桌面应用,我想在开机运行这个应用 

依照网上的推荐方法新建 /etc/rc.local 文件 

使用 sudo /ect/rc.local 测试没问题

但是重启以后rc-local服务报错

错误如下:


rc.local 文件 内容如下

本人萌新一个问题可能问的点···,但求大佬帮助,好人一生平安

Reply Favorite View the author
All Replies
a***1@163.com
deepin
2020-12-26 07:13
#1

deepin没玩过这个文件启动。


树莓派玩过,你可以参考着玩儿。

给需要启动运行的程序写一个sh脚本。比如:

#!/bin/bash
./wyc_linux_arm -token 令牌


放到/home/pi/ 目录

这个rc.local里需要先加个延迟一分钟启动,就是sleep 1m。

(网上有说法是这个方式设置的启动加载程序不稳定,跟优先级有关)

在exit0前面加上的大概就是如下:

sleep 1m
/home/pi/wyc.sh start


这样就基本没问题了,我用这个办法没发现起不来过。

甚至跟syncting到init启动文件同时干到系统里这个启动都没问题。


Reply View the author
走钢丝
deepin
2020-12-26 07:17
#2

带界面的应该加入 xorg 会话的配置文件中,当然一般是用户配置。


Reply View the author
a***1@163.com
deepin
2020-12-26 07:18
#3

只是举个例子,你可以参考写对应的脚本。

然后放到对应目录最后改rc.local文件完事。


不过话说回来deepin下有些东西和别的linux有点出入。

比如apach2的以端口部署多个网站来说,deepin简直不要太爽。

改很少的一个配置就完事了,别的系统还得多搞几下。

应该都差不多,反正自己折腾着玩儿挺好玩。

Reply View the author
deepinuser17
deepin
2020-12-26 08:38
#4

命令"sudo -i"需要打开一个shell环境.

在手动运行时, 这个没有问题, 因为已经是在一个shell环境下了.

系统启动时自动执行的命令是在没有shell环境下运行的. 

-i, --login
Run the shell specified by the target user's password database entry as a login shell. This means that login-specific resource files such as .profile,
.bash_profile or .login will be read by the shell. If a command is specified, it is passed to the shell for execution via the shell's -c option. If no command is
specified, an interactive shell is executed. sudo attempts to change to that user's home directory before running the shell. The command is run with an environ‐
ment similar to the one a user would receive at log in. Note that most shells behave differently when a command is specified as compared to an interactive session;
consult the shell's manual for details. The Command environment section in the sudoers(5) manual documents how the -i option affects the environment in which a
command is run when the sudoers policy is in use.


取消"-i", 只用"sudo -u <用户名> ....."试试.


深度20已经转为systemd.  最好是使用systemd的启动服务.  你可以创建一个启动文件, 例如

/etc/systemd/system/tier.service.


如何创建启动文件见这个链接:

https://www.devdungeon.com/content/creating-systemd-service-files


可以用百度翻译成中文.

 

Reply View the author
SamLukeYes
deepin
2020-12-26 16:52
#5

应用的开机启动,直接把启动器放 ~/.config/autostart 里面

Reply View the author