我一直在尝试在ubuntu 16.04 上使用 docker(1.10),但是安装失败是因为 docker服务没有启动. 我已经尝试通过 docker.io , docker-engine apt packages和curl -sSL https://get.docker.com/ | sh安装docker. 我的主机信息是: Linux Xenial 4.5.3-040503-generic #201605041831 SMP Wed May 4 22:33:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux 这是 systemctl status docker.service : ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor
以下是关于 systemctl 的编程技术问答
我正在尝试创建一项服务,以由Ubuntu上的.NET应用程序运行. cd/lib/systemd/system/yellowpages.service [Unit] Description = Yellow pages .NET service [Service] Type=forking WorkingDirectory=/home/yp_app ExecStart=dotnet /home/yp_app/YellowPages.dll [Install] WantedBy=multi-user.target ~ 我在/home/yp_app上有我的申请. 我运行时:SystemD启动Yellowpages.Service 我明白了 过多的论点. 所以我尝试了:SystemCtl启动Yellowpages.Service 我得到 Failed to start YellowPages.service: Unit YellowPages.servi
我尝试在Ubuntu 14.04中执行以下命令: systemctl enable --now docker-cleanup-dangling-images.timer 我还尝试了Sudo,我尝试用Service和SystemD替换SystemCtl,但没有任何作用 sudo: systemd: command not found systemd: command not found sudo: service: command not foud 如何在Ubuntu 14.04中执行此命令,或者有其他方法可以执行同一命令? 解决方案 我刚刚遇到了这个问题,发现Ubuntu 14.04用完了Upstart而不是SystemD,因此SystemCtl命令将行不通.这在15.04发生了变化,因此解决此问题的一种方法是更新Ubuntu安装. 如果这不是您的选项(现在不适合我),则需要查找执行您需要做的事情的Upstart命令. 为启用,通用看起来如下:
我有一个Python应用程序,我需要作为服务运行,我尝试了许多方法,建议我将其作为Systemd Service 我搜索并尝试了一些代码 这是我的单位代码 [Unit] Description=Airnotifier Service After=network.target [Service] Type=idle Restart=on-failure User=root ExecStart=python3 /home/airnotifier/airnotifier/app.py [Install] WantedBy=multi-user.target 然后我运行以下命令 sudo systemctl daemon-reload sudo systemctl enable airnotifier.service sudo systemctl start airnotifier.service sudo systemctl status airnotifier
我们试图在Ubuntu 16.04.2的启动时间使Obossh连接到远程服务器.因此,我们使用SystemCTL来完成这项工作.脚本如下: [Unit] Description=Keeps a tunnel to 'remote server' open After=network.target [Service] ExecStart=/usr/bin/autossh -NR 83232:localhost:22 -i /home/user/.ssh/id_rsa REMOTE_USER@REMOTE_IP [Install] WantedBy=multi-user.target 如果我们使用start 开始服务,则可以正常工作 systemctl start SERVICE ,如果我们使用启用服务 ,那将失败 systemctl enable SERVICE 错误代码为 " SSH:连接到主机远程_ip端口22:网络无法实现" 任何人都可以提供
我有以下服务文件: [Unit] Description=MyApp After=syslog.target network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 WorkingDirectory=/opt/nodejs-sites/MyApp ExecStart=/usr/bin/npm start Environment=NODE_ENV=development User=root Group=root StandardOutput=syslog StandardError=syslog SyslogIdentifier=MyApp [Install] WantedBy=multi-user.target 这是/var/log/syslog的错误 Oct 14 13:00:55 devu18 systemd[1]: Started myapp
我正在尝试将我的ASP .NET Core应用程序作为Ubuntu 16.04下的服务运行. 我已经创建了服务配置以下此文档 [Unit] Description=TNW Main Service [Service] WorkingDirectory=/home/tnw ExecStart=/usr/bin/dotnet /home/tnw/Tnw.MealsApi.dll Restart=always RestartSec=10 SyslogIdentifier=tnw User=www-data Environment=ASPNETCORE_ENVIRONMENT=Production [Install] WantedBy=multi-user.target 我已经启用了我的服务: sudo systemctl enable tnw.service 最后我尝试运行它,但我得到了例外: ● tnw.service - TNW Main Service Lo
我如何在Ubuntu 16.04 LTS上运行MongoDB作为服务? 几天前,我将服务器升级到Ubuntu 16.04.我注意到我的MongoDB服务重新启动时不会启动. 尝试使用 sudo initctl start mongod 没有解决问题. 任何人都知道如何解决这个问题? 解决方案 任何升级或安装Ubuntu 16.04(也称为Ubuntu Xenial Xerus)的人都注意到,一些旧服务停止运行. 此问题是从版本15.04中知道的,但我将重点介绍上述版本. 这就是我与MongoDB的案子.简而言之,Ubuntu从Upstart转移到Systemd.这些问题的一种常见解决方案是切换回Upstart.我不认为该选项是一个真正的解决方案,从长远来看肯定不是. 问题的真正解决方案(IMHO)是编写将启动MongoDDB的SystemD脚本.不幸的是,MongoDB的家伙尚未提供. 所以我不得不从头开始写一个.要创建自己的一个步骤: 使用使用
我有一个python脚本myScript.py,该脚本每2秒钟在文件上写入.但是,当我想以systemd服务运行此脚本时,服务有效但不在文件上写作. 我在/lib/systemd/system/上创建了myscript.service文件 并按照下面的方式设计: [Unit] Description=My Script Service After=multi-user.target [Service] Type=idle ExecStart=/usr/bin/python /home/pala/PycharmProjects/myScript.py [Install] WantedBy=multi-user.target 和myScript.py是: import time while True: with open("/home/pala/Documents/file.txt", "a") as myFile: myFile.writ
我总是以这种方式运行我的apache服务器: sudo service apache2 start 但是在许多指南中,我看到了这样的命令: sudo systemctl start apache2 有人可以简短地写下这些命令之间的区别,并就我在日常工作中使用的命令提供建议? 解决方案 service在/etc/init.d 中的文件上操作,并与旧的Init System一起使用. systemctl在/lib/systemd 中的文件上操作.如果在/lib/systemd 中有一个用于您的服务的文件,它将首先使用,如果没有,它将返回到/etc/init.d 中的文件. 另外,如果您使用的是ubuntu-14.04这样的操作系统,则只有服务命令可用. 因此,如果可以使用 Systemctl ,最好使用它 其他解决方案 从中借来的借款 service是用于start,restart, stop和status的"高级"命令 不同的 Unixes
问题 似乎systemd在Ubuntu Docker容器中没有活动或可用. 设置 我正在运行ubuntu:16.04和ubuntu:16.10图像的Docker容器. 测试 如果我执行: systemctl status ssh在16,04容器中 结果是错误Failed to connect to bus: No such file or directory 在16.10容器中,错误是:bash: systemctl: command not found. 如果我在16.04容器中找到which systemctl systemctl,但在16.10容器中找不到. 我发现存在/lib/systemd. 我尝试使用以下方式安装SystemD: apt-get install systemd libpam-systemd systemd-ui 然后which systemctl在16.10 中找到systemct
我已经为我的春季启动应用程序制作了Docker映像.我无法在Docker容器内运行SystemCtl命令.这是我执行 时得到的 systemctl daemon reload: - Failed to connect to bus: No such file or directory 我遵循的步骤构建docker映像: - 1)docker build --rm -t . 2)docker-compose up 3)docker exec -it bash 我使用以下方式启动服务时: - service start 我获得了无法识别的服务.如何在Docker内部执行服务? 解决方案 如果要重复使用现有的SystemD服务描述符,则您要么需要运行Systemd作为入口点,要么可以使用包装脚本,例如 docker-systemctl-replac
已经挖了一段时间了.我回顾了有关此问题的多个文章.这是最接近的: tomcat 8 Centos 7上没有作为服务开始(但它是手动开始的....) 区别在于我正在运行Tomcat 9.0.33.以下是: java version "1.8.0_121"\ Java(TM) SE Runtime Environment (build 1.8.0_121-b13)\ Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)\ Tomcat 9.0.33 NAME="CentOS Linux"\ VERSION="7 (Core)"\ ID="centos"\ ID_LIKE="rhel fedora"\ VERSION_ID="7"\ PRETTY_NAME="CentOS Linux 7 (Core)"\ ANSI_COLOR="0;31"\ CPE_NAME="cpe:/o:centos:cen
我正在尝试使用SystemD运行Python3脚本,它工作正常,但是我更改了Python脚本以使用内置的OS模块,因为我想从系统中检索一个环境变量以在Python中使用脚本作为变量. Python脚本如下: #/usr/bin/python import sys, requests, json, time, os import paho.mqtt.client as mqtt from requests.auth import HTTPBasicAuth from datetime import datetime MQTT_DEVICE_ID = os.environ['DEVICE_ID']+"/DEFENCE" DEVICE_ID enviroment变量来自我在/etc/enviroment中设置的一个: export DEVICE_ID="TEST1" user@computer:~ $ echo $DEVICE_ID TEST1 将此更改添加到我
我遵循此链接的说明: https://www.thegeekdiary.com/centos-rhel-7-how-to-make-custom-custom-script-script-to-run-aut---------- /p> 但是我有问题,因为我的服务没有运行. 我创建了一个stript startanic2.sh,该脚本调用startanic.sh脚本(我需要这个脚本,因为当我手动启动它时&仅在这种情况下不会过期) 这是我的脚本startanic2.sh # cat /opt/horses/startSanic2.sh #!/bin/bash cd /opt/horses ./startSanic.sh & 这是我的脚本startanic.sh # cat /opt/horses/startSanic.sh #!/bin/bash gunicorn horses.server:app --bind 0.0.0.0:9000 --worker
我有2个服务A.Service和B.Service. A.Service显示 [Unit] Description=My service [Service] Type=forking ExecStart=/bin/sh /home/admin/run.sh Restart=on-failure [Install] WantedBy=multi-user.target, B.Service [Unit] Description=My service [Service] Type=forking ExecStart=/bin/sh $HOME/theFolder/run.sh Restart=on-failure [Install] WantedBy=multi-user.target 现在,当我启动B.服务时,我敢肯定会启动服务. 在运行时,突然有人与/home/admin/run.sh混乱了,Systemd无法启动a.service(SystemCtl状态A.
喜欢使用systemctl is-active 给出的是,如果服务处于活动状态或失败,则可以使用SystemCtl? time systemctl status kdm|cat * kdm.service - LSB: X display manager for KDE Loaded: loaded (/etc/init.d/kdm; generated; vendor preset: enabled) Active: active (exited) since Wed 2017-06-21 12:03:26 CEST; 1h 42min ago Docs: man:systemd-sysv-generator(8) Tasks: 0 (limit: 4915) CGroup: /system.slice/kdm.service 可以使用SystemCtl 获得 1H 42min 解决方案 使用SystemCtl的
SystemD支持别名.例如" httpd.service" ls -l /etc/systemd/system/httpd.service /etc/systemd/system/httpd.service -> /usr/lib/systemd/system/apache2.service 此文件的内容: [Unit] Description=The Apache Webserver ... [Install] WantedBy=multi-user.target Alias=httpd.service apache.service 我想在脚本中解析别名. 示例: 如果输入为" httpd.service",则输出应为" apache2.service" 我可以在此脚本中使用Shell或Python. 如何执行Systemd-way? 阅读Symlink可能会起作用,但我想有一种更正式的方法可以解决别名. 解决方案 您应该
我在自动运行服务方面有问题.我想在用户登录后运行脚本.一旦我成功了,但是当我尝试自动化它时,我会遇到错误,而我找不到错误. 服务: Description=Service desc [Service] Type=oneshot Environment=DISPLAY=:0.0 Environment=XAUTHORITY=/home/albert/.Xauthority Environment=HOME=/home/albert/ User=albert Group=albert RemainAfterExit=true StandardOutput=journal ExecStart=/home/albert/.startup-script.sh [Install] WantedBy=default.target 位置: /home/albert/.config/systemd/user/startup-service.service 许可:-RW-R--R
这是我的问题.我有CentOS和Java流程在上面运行. Java进程由开始/停止脚本操作.它也创建了一个.pid文件的Java实例. 我的单位文件看起来像: [Unit] After=syslog.target network.target Description=Someservice [Service] User=xxxuser Type=forking WorkingDirectory=/srv/apps/someservice ExecStart=/srv/apps/someservice/server.sh start ExecStop=/srv/apps/someservice/server.sh stop PIDFile=/srv/apps/someservice/application.pid TimeoutStartSec=0 [Install] WantedBy=multi-user.target 当我调用stop函数时,脚本用SIGTERM终止