首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >终端上的命令工作,但不作为系统服务Ubuntu18.04服务器

终端上的命令工作,但不作为系统服务Ubuntu18.04服务器
EN

Server Fault用户
提问于 2020-01-19 19:10:32
回答 1查看 349关注 0票数 1

我一次又一次地检查了终端和./go.sh的运行情况,但无法作为服务启动。我知道我做错了,但不确定是什么。

代码语言:javascript
复制
/root/go.sh

#!/usr/bin/env bash
export PATH=/sbin:/usr/sbin:/bin:/usr/bin

/root/goweb/bin/echoip -t=/root/goweb/bin/index.html

代码语言:javascript
复制
/lib/systemd/system/goweb.service

[Unit]
Description=goweb

[Service]
Type=forking
Restart=always
RestartSec=5s
ExecStart=/root/go.sh

[Install]
WantedBy=multi-user.target

我不知道现在发生了什么,服务开始,停止,开始,停止

代码语言:javascript
复制
Here is the status

goweb.service - goweb
   Loaded: loaded (/lib/systemd/system/goweb.service; enabled; vendor preset: en
   Active: activating (start) since Sun 2020-01-19 19:39:52 UTC; 36s ago
Cntrl PID: 1259 (bash)
    Tasks: 6 (limit: 1151)
   CGroup: /system.slice/goweb.service
           ├─1259 bash /root/go.sh
           └─1268 /root/goweb/bin/echoip -t=/root/goweb/bin/index.html

Jan 19 19:39:52 ip systemd[1]: goweb.service: Service hold-off time over, schedu
Jan 19 19:39:52 ip systemd[1]: goweb.service: Scheduled restart job, restart cou
Jan 19 19:39:52 ip systemd[1]: Stopped goweb.
Jan 19 19:39:52 ip systemd[1]: Starting goweb...
Jan 19 19:39:52 ip go.sh[1259]: echoip: Listening on http://0.0.0.0:8080
EN

回答 1

Server Fault用户

发布于 2020-01-19 19:18:21

添加到脚本go.sh的顶部

代码语言:javascript
复制
export PATH=/sbin:/usr/sbin:/bin:/usr/bin

如果需要更多的路径,将它们添加到上面,或者将完整的路径添加到任何脚本或命令中,则需要在脚本上执行。

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/999565

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档