Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何让脚本开机自启,一直在后台运行? #1

Open
kxjhcmc opened this issue Jun 26, 2022 · 3 comments
Open

如何让脚本开机自启,一直在后台运行? #1

kxjhcmc opened this issue Jun 26, 2022 · 3 comments

Comments

@kxjhcmc
Copy link

kxjhcmc commented Jun 26, 2022

如题

@kxjhcmc
Copy link
Author

kxjhcmc commented Jun 26, 2022

我目前用以下systemd代码自启动,能成功在后台运行,但是json文件不能被改写,网页看不到最新数据。
[Unit]
Description=Run a Custom Script at Startup
After=default.target

[Service]
User=root
ExecStart=/home/status.sh

[Install]
WantedBy=multi-user.target

@badafans
Copy link
Owner

badafans commented Nov 6, 2022

可以使用screen来管理

@asmallbit
Copy link

此处写入的是这个文件$server_name.jsonserver_name是我们在这里指定的。
本着尽量简单的原则,我们可以将
ExecStart=/home/status.sh
改为
ExecStart=cd your_destination_path && /home/status.sh
这样应该可以正确写入到此路径下的status.json
第二种方法是直接将这里server_name直接赋值为status.json文件的绝对路径。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants