不幸的是,在我的 Debian 8 中,jessie systemctl 根本不起作用。
每个systemctl命令都会导致:
Failed to get D-Bus connection: Unknown error -1
系统状态 udev
无法获得 D-Bus 连接:未知错误 -1
我该如何解决?
我会很感激你的帮助。
我有一个较旧的 initd 脚本来启动我的应用程序。它在旧版本的 SuSE 下运行良好,但在 Open SuSE 12.3 上失败。
奇怪的是
cd /etc/init.d ; ./script start
Run Code Online (Sandbox Code Playgroud)
工作正常。
/etc/init.d/script start
Run Code Online (Sandbox Code Playgroud)
显示重定向到 systemctl,但不启动我的应用程序(也不显示 initd 脚本的任何输出)。
我没有看到任何日志条目显示出了什么问题。我看到的唯一条目是在 /var/log/messages 中,说明应用程序已启动。
我该如何调试?
我正在尝试在单元文件中设置一个日期以进行记录
我的单元文件如下所示:
[Unit]
Description=Jetty service
After=multiuser.target
[Service]
Environment=MAIN_CLASS="com.candorgrc.nphase.MainJetty"
Type=simple
User=jetty
Group=jetty
WorkingDirectory=/home/jetty/dist
PermissionsStartOnly=true
ExecStartPre=/bin/systemctl set-environment date=$(/bin/date +%%Y-%%m-%%d-%%H-%%M)
ExecStart=/usr/bin/java -Xms512m -Xmx1024m -Djava.util.logging.config.file=/home/jetty/logging.properties -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/u01/jetty/hdumps/hdump_${date} -verbose:gc -Dcom.sun.management.jmxremote.port=12321 -Dcom.sun.management.jmxremote.authen
PIDFile=/var/run/jetty.pid
ExecReload=/bin/kill -HUP $MAINPID
#Restart=on-failure
ExecStop=/bin/kill -9 $MAINPID
Run Code Online (Sandbox Code Playgroud)
设置日期并不能正常工作。我得到的错误如下:
Nov 26 16:47:50 vps203756 systemctl[14275]: Failed to set environment: Invalid environment assignments
Nov 26 16:47:50 vps203756 systemd[1]: jetty.service: Control process exited, code=exited status=1
Nov 26 16:47:50 vps203756 systemd[1]: jetty.service: Failed with result 'exit-code'.
Nov 26 16:47:50 vps203756 systemd[1]: Failed to start Jetty service.
Run Code Online (Sandbox Code Playgroud)
知道如何配置它才能工作吗?
我正在运行 apache2.4 Web 服务器,并注意到当我运行systemctl status apache2或运行时service apache2 status,它说它使用的是 4.2GiB 的 RAM,这对于我拥有的 RAM 量来说不是问题,但我很困惑,因为top并且htop两者都显示仅使用了 500MiB 的 RAM,更不用说systemctl单独使用 apache2 的报告了。为什么会这样,哪个是正确的?
操作系统信息,如果需要:
OS: Kali GNU/Linux Rolling x86_64
Kernel: 4.19.0-kali3-amd64
Run Code Online (Sandbox Code Playgroud) 我使用 Debian 9 通过 ssh 连接到 google 计算实例。当我尝试任何systemctl --user ...命令(systemctl --user status例如)时,我收到错误:“无法连接到总线:没有这样的文件或目录”。
我尝试设置 XDG_RUNTIME_DIR=/run/user/$(id -u) 并注意到 /run/user 中没有创建目录。
我还安装了 dbusapt install dbus并确保 dbus.service 正在运行(最初没有安装)。
sshd_config 默认情况下具有UsePAM yes.
有没有办法从 systemctl 状态获得更短/自定义的输出?我实际上只需要在活动行前面加上服务名称。所以像这样:
\n\n apache2: active (running) since Thu 2020-02-06 17:20:42 +03; 16min ago\n mongodb: inactive (dead) since Thu 2020-02-06 17:20:47 +03; 16min ago\nrabbitmq-server: active (running) since Thu 2020-02-06 17:20:52 +03; 16min ago\n mongodb-server: active (running) since Thu 2020-02-06 17:20:54 +03; 16min ago\n mysql: active (running) since Thu 2020-02-06 17:20:57 +03; 16min ago\nRun Code Online (Sandbox Code Playgroud)\n\n仅具有颜色反馈。但我会接受没有颜色的。或者在两行加上一个空行,例如:
\n\n\xe2\x97\x8f apache2.service - The Apache HTTP Server\n Active: active (running) since Thu 2020-02-06 17:20:42 +03; 16min ago\n\n\xe2\x97\x8f mongodb.service - An object/document-oriented database\n Active: inactive …Run Code Online (Sandbox Code Playgroud) 这里是 Unix 新手。我正在尝试从gunicorn开始systemctl。没有出现错误消息,但它也没有显示在进程列表中:
$ sudo systemctl start gunicorn\n$ ps aux | grep gunicorn\ntest+ 29902 0.0 0.0 14224 924 pts/0 S+ 11:13 0:00 grep --color=auto gunicorn\nRun Code Online (Sandbox Code Playgroud)\n\n有没有可能它正在运行,但不可见?
\n\n或者如果没有,我该如何调试它没有运行的原因?
\n\n更新:刚刚尝试systemctl status gunicorn并得到了这个:
\xe2\x97\x8f gunicorn.service - Gunicorn Application Server handling myapp\n Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)\n Active: inactive (dead) (Result: exit-code) since Mon 2016-10-31 11:24:04 EDT; 1min 25s ago\n Process: 30135 ExecStart=/.venv/bin/gunicorn --workers 3 --bind unix:/home/myapp/myapp/myapp.sock myapp.wsgi:application (code=exited, status=200/CHDIR)\n Main …Run Code Online (Sandbox Code Playgroud)