我正在安装 Tomcat,最后一个步骤需要为它定义一个 .service 文件。在该文件中,我必须定义一行
Environment="JAVA_HOME=path_to_java"
我已经定义了一个 JAVA_HOME 环境变量,有没有办法从 .service 文件中指向它?就像是:
Environment="JAVA_HOME=$JAVA_HOME"
我正在安装 Tomcat,最后一个步骤需要为它定义一个 .service 文件。在该文件中,我必须定义一行
Environment="JAVA_HOME=path_to_java"
我已经定义了一个 JAVA_HOME 环境变量,有没有办法从 .service 文件中指向它?就像是:
Environment="JAVA_HOME=$JAVA_HOME"
我在 ubuntu 服务器上以普通用户身份登录,我需要在端口 80 上启动服务。到目前为止,它不允许我这样做,因为它是为管理员用户保留的。
但是我确实在另一台 ubuntu 服务器上看到了相同类型的用户,该用户已启动服务并使用端口 80。我想让当前用户设置为达到相同的行为,但我不知道该怎么办?我完全控制了这个 ubuntu 服务器。
这是我在该服务器上的服务当前状态:
systemctl -l status gns3.service
● gns3.service - GNS3 server
Loaded: loaded (/lib/systemd/system/gns3.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2022-03-23 16:57:07 UTC; 4s ago
Process: 78994 ExecStartPre=/bin/mkdir -p /var/log/gns3 /var/run/gns3 (code=exited, status=0/SUCCESS)
Process: 79003 ExecStartPre=/bin/chown -R gns3:gns3 /var/log/gns3 /var/run/gns3 (code=exited, status=0/SUCCESS)
Process: 79007 ExecStart=/usr/local/bin/gns3server --log /var/log/gns3/gns3.log (code=exited, status=1/FAILURE)
Main PID: 79007 (code=exited, status=1/FAILURE)
这是服务日志文件中的内容:
tail -10 /var/log/gns3/gns3.log
2022-03-23 17:13:13 INFO run.py:224 Config file /etc/gns3/gns3_server.conf loaded
2022-03-23 17:13:13 INFO run.py:243 Running with Python 3.8.10 and has PID 82762
2022-03-23 17:13:13 INFO run.py:79 Current locale is en_US.UTF-8
2022-03-23 17:13:13 INFO web_server.py:318 Starting server on 0.0.0.0:80
2022-03-23 17:13:13 INFO __init__.py:63 Load controller configuration file /etc/gns3/gns3_controller.conf
2022-03-23 17:13:13 INFO __init__.py:67 Controller is starting
2022-03-23 17:13:13 INFO compute.py:64 Create compute local
2022-03-23 17:13:13 INFO compute.py:364 Connecting to compute 'local'
2022-03-23 17:13:13 WARNING compute.py:367 Cannot connect to compute 'local': Cannot connect to host 127.0.0.1:80 ssl:default [Connect call failed ('127.0.0.1', 80)]
2022-03-23 17:13:13 CRITICAL web_server.py:88 Could not start the server: [Errno 13] error while attempting to bind on address ('0.0.0.0', 80): permission denied
该系统建立在 ubuntu 20.4 映像之上。
我继承了在 Ubuntu 16.04.3 x64 droplet 上运行的 WordPress 5.7 站点,该站点使用单独的 DigitalOcean 管理的 MySQL 8 数据库。
WordPress 站点是一个 Trellis LEMP 堆栈站点。PHP 版本 7.3,但 Nginx 似乎正在使用 phpinfo() 中的 7.1。
我知道所有版本都严重过时并且需要更新,但在非常近期内,我需要首先让事情正常工作。
出现数据库连接错误(请参阅https://www.digitalocean.com/community/questions/since-a-wordpress-url-change-i-can-t-connect-to-do-managed-mysql-database)这涉及到我尝试了很多不明智的事情,直到现在通过格子部署到临时站点失败。
它是这样说的:
任务 [部署:重新加载 php-fpm] ***************************************** ************************************************ 系统信息:Ansible 2.7.0;“从 .dev 切换到 .test”中的 Linux Trellis -------------------------------------------------- ------------- 致命:[staging.mywebsite.co.uk]:失败!=> {“更改”:true,“cmd”:“sudo service php7.3-fpm reload”,“delta”:“0:00:00.030313”,“end”:“2021-12-21 11:51: 06.490541”,“msg”:“非零返回码”,“rc”:1,“start”:“2021-12-21 11:51:06.460228”,“stderr”:“php7.3-fpm.service未激活,无法重新加载。”,“stderr_lines”:[“php7.3-fpm.service 未激活,无法重新加载。”],“stdout”:“”,“stdout_lines”:
如果我 SSH 并尝试启动我得到的服务
php7.3-fpm.service 的作业失败,因为控制进程以错误代码退出。有关详细信息,请参阅“systemctl status php7.3-fpm.service”和“journalctl -xe”。
这是 systemctl 状态 php7.3-fpm.service:
● php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-12-21 12:04:49 GMT; 47min ago
Docs: man:php-fpm7.3(8)
Process: 1658 ExecStart=/usr/sbin/php-fpm7.3 --nodaemonize --fpm-config /etc/php/7.3/fpm/php-fpm.conf (code=exited, st
Main PID: 1658 (code=exited, status=78)
Dec 21 12:04:49 ubuntu-xxx-xxx-01 systemd[1]: Starting The PHP 7.3 FastCGI Process Manager...
Dec 21 12:04:49 ubuntu-xxx-xxx-01 php-fpm7.3[1658]: [21-Dec-2021 12:04:49] ERROR: Another FPM instance seems to already
Dec 21 12:04:49 ubuntu-xxx-xxx-01 php-fpm7.3[1658]: [21-Dec-2021 12:04:49] ERROR: FPM initialization failed
Dec 21 12:04:49 ubuntu-xxx-xxx-01 systemd[1]: php7.3-fpm.service: Main process exited, code=exited, status=78/n/a
Dec 21 12:04:49 ubuntu-xxx-xxx-01 systemd[1]: Failed to start The PHP 7.3 FastCGI Process Manager.
Dec 21 12:04:49 ubuntu-xxx-xxx-01 systemd[1]: php7.3-fpm.service: Unit entered failed state.
Dec 21 12:04:49 ubuntu-xxx-xxx-01 systemd[1]: php7.3-fpm.service: Failed with result 'exit-code'.
和 journalctl -xe:
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-9.scope has finished starting up.
--
-- The start-up result is done.
Dec 21 12:53:07 ubuntu-xxx-xxx-01 sshd[1915]: Received disconnect from 92.0.0.0 port 53386:11: Bye Bye [preauth]
Dec 21 12:53:07 ubuntu-xxx-xxx-01 sshd[1915]: Disconnected from 92.0.0.0 port 53386 [preauth]
Dec 21 12:55:34 ubuntu-xxx-xxx-01 sudo[1919]: root : TTY=pts/0 ; PWD=/root ; USER=root ; COMMAND=/bin/systemctl sta
Dec 21 12:55:34 ubuntu-xxx-xxx-01 sudo[1919]: pam_unix(sudo:session): session opened for user root by root(uid=0)
Dec 21 12:55:34 ubuntu-xxx-xxx-01 systemd[1]: Starting The PHP 7.3 FastCGI Process Manager...
-- Subject: Unit php7.3-fpm.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit php7.3-fpm.service has begun starting up.
Dec 21 12:55:34 ubuntu-xxx-xxx-01 php-fpm7.3[1922]: [21-Dec-2021 12:55:34] ERROR: Another FPM instance seems to already
Dec 21 12:55:34 ubuntu-xxx-xxx-01 php-fpm7.3[1922]: [21-Dec-2021 12:55:34] ERROR: FPM initialization failed
Dec 21 12:55:34 ubuntu-xxx-xxx-01 systemd[1]: php7.3-fpm.service: Main process exited, code=exited, status=78/n/a
Dec 21 12:55:34 ubuntu-xxx-xxx-01 systemd[1]: Failed to start The PHP 7.3 FastCGI Process Manager.
-- Subject: Unit php7.3-fpm.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit php7.3-fpm.service has failed.
--
-- The result is failed.
我被困住了。我对 Linux 环境不是很有信心,所以说实话我完全迷路了。我想我需要先解决这个问题,然后再修复我的数据库连接错误!
我确实尝试添加 PHP 7.4,但是当我尝试部署站点时,这会产生几页红色错误,因此我将其删除。
这是一个临时站点,所以它并不重要,但显然生产站点具有相同的背景设置,我很害怕它也会崩溃!
从长远来看,我计划升级所有东西,但真的很想得到一些帮助,以使其在短期内正常工作。
谢谢!
WSL2 Ubuntu 20.04.3 LTS 内核映像:5.10.60.1-microsoft-standard-WSL2
我正在尝试根据此处的说明安装 CUDA:https ://ubuntu.com/blog/getting-started-with-cuda-on-ubuntu-on-wsl-2
docker: unrecognized service
运行命令时我收到一条消息sudo service docker stop
。我确实按照教程中的该命令的说明进行操作,并且运行结果sudo apt update && sudo apt install -y nvidia-docker2
似乎成功。我还尝试检查 docker 服务是否完全可用,service --status-all
但在结果中没有看到。
请帮我弄清楚如何正确安装 CUDA,我正在尝试为我正在从事的图像处理项目设置带有 GPU 支持的 opencv。
以下是我运行的上述命令的输出:
service --status-all
输出:
[ - ] apparmor
[ ? ] apport
[ - ] atd
[ - ] console-setup.sh
[ - ] cron
[ ? ] cryptdisks
[ ? ] cryptdisks-early
[ - ] dbus
[ ? ] hwclock.sh
[ + ] irqbalance
[ - ] iscsid
[ - ] keyboard-setup.sh
[ ? ] kmod
[ - ] lvm2
[ - ] lvm2-lvmpolld
[ - ] multipath-tools
[ + ] open-iscsi
[ - ] open-vm-tools
[ ? ] plymouth
[ ? ] plymouth-log
[ - ] procps
[ - ] rsync
[ - ] rsyslog
[ - ] screen-cleanup
[ - ] ssh
[ ? ] ubuntu-fan
[ + ] udev
[ - ] ufw
[ - ] unattended-upgrades
[ - ] uuidd
[ - ] x11-common
命令:
sudo apt update && sudo apt install -y nvidia-docker2
输出:
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 https://nvidia.github.io/libnvidia-container/experimental/ubuntu18.04/amd64 InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:5 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64 InRelease
Hit:6 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:7 https://nvidia.github.io/nvidia-container-runtime/stable/ubuntu18.04/amd64 InRelease
Hit:8 https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64 InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
nvidia-docker2 is already the newest version (2.8.0-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
尽管我在 AskUbuntu 上经历了很多线程,但我找不到禁用这些 Evolution 服务的正确方法,尤其是在 Ubuntu MATE 21.04 中已经从系统中清除了 Evolution 时。
这些服务没有在下面列出systemctl list-unit-files --type=service
,所以我不能使用sudo systemctl mask
。
ps -ef | grep evolution
admn 1973 1459 0 17:15 ? 00:00:00 /usr/libexec/evolution-source-registry
admn 2023 1459 0 17:15 ? 00:00:00 /usr/libexec/evolution-calendar-factory
admn 2058 1459 0 17:15 ? 00:00:00 /usr/libexec/evolution-addressbook-factory
这 2 个 Evolution 相关的软件包仍然存在,因为清除它们会删除许多其他软件包。
evolution-data-server
evolution-data-server-common
结果ls -lsh /usr/libexec/evolution*
:
$ ls -lsh /usr/libexec/evolution*
16K -rwxr-xr-x 1 root root 15K Jun 22 20:57 /usr/libexec/evolution-addressbook-factory
48K -rwxr-xr-x 1 root root 47K Jun 22 20:57 /usr/libexec/evolution-addressbook-factory-subprocess
116K -rwxr-xr-x 1 root root 115K Jun 22 20:57 /usr/libexec/evolution-calendar-factory
136K -rwxr-xr-x 1 root root 135K Jun 22 20:57 /usr/libexec/evolution-calendar-factory-subprocess
60K -rwxr-xr-x 1 root root 59K Jun 22 20:57 /usr/libexec/evolution-scan-gconf-tree-xml
124K -rwxr-xr-x 1 root root 123K Jun 22 20:57 /usr/libexec/evolution-source-registry
20K -rwxr-xr-x 1 root root 19K Jun 22 20:57 /usr/libexec/evolution-user-prompter
/usr/libexec/evolution-data-server:
total 116K
32K -rwxr-xr-x 1 root root 31K Jun 22 20:57 addressbook-export
8.0K -rwxr-xr-x 1 root root 7.0K Jun 22 20:57 csv2vcard
52K -rwxr-xr-x 1 root root 51K Jun 22 20:57 evolution-alarm-notify
24K -rwxr-xr-x 1 root root 23K Jun 22 20:57 list-sources
操作系统:Ubuntu 伴侣 21.04
进化数据服务器:3.40.0-1ubuntu1.1
进化数据服务器通用:3.40.0-1ubuntu1.1
提前非常感谢。
我正在使用 Kubuntu 20.04,并且在disk manager
所以我想问题是disk manager
接下来应该出现的服务(很高兴知道下一个服务)。
我使用的是 AMD CPU 和 GPU,在更新之前一切都运行良好。从那时起,我清理了所有不需要的 ppa(所以 steam、spotify 和 wineHQ)仍然安装,但它们不应该干扰系统。我比较了来自实时系统的所有包并安装了缺少的一个,并且还重新配置了每个包dpkg-reconfigure
而不做任何更改。
在引导期间,我没有看到任何失败的服务..
我想让它再次运行,而无需重新安装。感谢您的时间。
编辑
从旧的 Boot.log 它应该停在这里:
Starting Snap Daemon...
Starting Login Service...
Starting Thermal Daemon Service...
Starting Disk Manager...
Starting LSB: This service…d stops the USB Arbitrator....
Starting WPA supplicant...
Starting Rotate log files...
Starting Daily man-db regeneration...
也许一个驱动器的 MBR/GPT 扇区出了问题?
sdc1: __________________________________________________________________________
File system:
Boot sector type: -
Boot sector info:
sdc2: __________________________________________________________________________
File system: ntfs
Boot sector type: Unknown
Boot sector info: According to the info in the boot sector, sdc2 has
1549178879 sectors, but according to the info from
fdisk, it has 5844146175 sectors.
Operating System:
Boot files:
在 WSL2(Linux 的 Windows 子系统)上使用 Ubuntu 20.04(焦点)作为 LAMP-stack/WordPress 开发环境。
由于所需的服务不会在 Windows 10(主/父操作系统)启动时自动运行,因此我创建了一个/start
文件来调用 start on openssl
、apache
和mysql
并回显确认语句。它看起来就像这个代码块。
#!/bin/sh
service ssh start
service mysql start
service apache2 start
echo "System ready."
现在,当我打开一个bash
终端时,我只是sudo -s
用来切换到 root 并调用/start
. 输出看起来像这样。
focal@DESKTOP-6FLTF67:~$ sudo -s
[sudo] password for focal:
root@DESKTOP-6FLTF67:/home/focal# /start
* Starting OpenBSD Secure Shell server sshd [ OK ]
* Starting MySQL database server mysqld [ OK ]
* Starting Apache httpd web server apache2
*
System ready.
root@DESKTOP-6FLTF67:/home/focal#
我如何使这项工作用于服务重启和关闭目的。是否允许为这些命令进行配置?因为我放置服务的顺序无关紧要,所以当我保存/restart
或/stop
文件并运行它时,我不断收到此错误。
focal@DESKTOP-6FLTF67:~$ sudo -s
root@DESKTOP-6FLTF67:/home/focal# /start
* Starting OpenBSD Secure Shell server sshd [ OK ]
* Starting MySQL database server mysqld [ OK ]
* Starting Apache httpd web server apache2
*
System ready.
*
root@DESKTOP-6FLTF67:/home/focal# /stop
bash: /stop: Permission denied
*
root@DESKTOP-6FLTF67:/home/focal# /restart
bash: /restart: Permission denied
*
root@DESKTOP-6FLTF67:/home/focal# /stop
bash: /stop: Permission denied
我已经尝试过关闭一个服务之前/之后关闭另一个服务的所有变体,等等,并根据工作/start
版本仔细检查了文件,它们似乎很好。
有人可以帮助我了解我所缺少的吗?先感谢您!
我不希望我的 systemd 服务在启动时运行并且我无法停止它。
我创建了自己的脚本、服务和计时器文件,用于自动备份到 Backblaze。我找到了 3 或 4 个关于此事的论坛帖子,但这些解决方案都没有帮助我。
如果我删除[Install]
.service 中的部分,状态将更改为static
. 它仍然在启动时运行。
这是我的 .service 文件:
ryley@pop-os:~$ cat /etc/systemd/system/b2backup.service
[Unit]
Description=Backblaze Backup Script
[Service]
User=ryley
Group=ryley
Type=simple
ExecStart=/home/ryley/b2backup.sh --full --to-external
Restart=on-failure
[Install]
WantedBy=multi-user.target
这是我的计时器文件:
ryley@pop-os:~$ cat /etc/systemd/system/b2backup.timer
[Unit]
Description=timer for Backblaze upload script
Requires=b2backup.service
[Timer]
Unit=b2backup.service
OnCalendar=Sun 03:00:00
[Install]
WantedBy=multi-user.target
这是状态:
ryley@pop-os:~$ systemctl status b2backup.service
● b2backup.service - Backblaze Backup Script
Loaded: loaded (/etc/systemd/system/b2backup.service; disabled; vendor preset: enabled)
Active: inactive (dead) since Mon 2020-11-23 20:58:30 PST; 12h ago
TriggeredBy: ● b2backup.timer
Process: 944 ExecStart=/home/ryley/b2backup.sh --full --to-external (code=exited, status>
Main PID: 944 (code=exited, status=0/SUCCESS)
这表明该服务已禁用:
ryley@pop-os:~$ systemctl list-unit-files --state=disabled
UNIT FILE STATE VENDOR PRESET
proc-sys-fs-binfmt_misc.mount disabled enabled
acpid.service disabled enabled
b2backup.service disabled enabled
任何帮助是极大的赞赏。我已经在这几个小时了。
每当我登录(或解锁密码屏幕)最近安装的 20.04 系统时,/var/log/syslog
报告它正在启动指纹验证守护进程:
…
Nov 15 13:29:28 ray-desktop dbus-daemon[528]: [system] Activating via systemd: service name='net.reactivated.Fprint' unit='fprintd.service' requested by ':1.193' (uid=1000 pid=8276 comm="/usr/bin/gnome-shell " label="unconfined")
Nov 15 13:29:28 ray-desktop systemd[1]: Starting Fingerprint Authentication Daemon...
Nov 15 13:29:28 ray-desktop dbus-daemon[528]: [system] Successfully activated service 'net.reactivated.Fprint'
Nov 15 13:29:28 ray-desktop systemd[1]: Started Fingerprint Authentication Daemon.
Nov 15 13:29:29 ray-desktop NetworkManager[86471]: <info> [1605464969.2480] agent-manager: agent[5d99141cf1aa3382,:1.193/org.gnome.Shell.NetworkAgent/1000]: agent registered
Nov 15 13:29:29 ray-desktop dbus-daemon[8052]: [session uid=1000 pid=8052] Activating service name='org.freedesktop.FileManager1' requested by ':1.42' (uid=1000 pid=8276 comm="/usr/bin/gnome-shell " label="unconfined")
Nov 15 13:29:29 ray-desktop dbus-daemon[8052]: [session uid=1000 pid=8052] Activating service name='org.gnome.Nautilus' requested by ':1.42' (uid=1000 pid=8276 comm="/usr/bin/gnome-shell " label="unconfined")
Nov 15 13:29:29 ray-desktop dbus-daemon[8052]: [session uid=1000 pid=8052] Successfully activated service 'org.gnome.Nautilus'
Nov 15 13:29:29 ray-desktop org.gnome.Nautilus[132137]: Failed to register: Unable to acquire bus name 'org.gnome.Nautilus'
Nov 15 13:29:29 ray-desktop dbus-daemon[8052]: [session uid=1000 pid=8052] Successfully activated service 'org.freedesktop.FileManager1'
…
Nov 15 13:29:58 ray-desktop systemd[1]: fprintd.service: Succeeded.
…
这是一台没有指纹硬件的台式机,为什么要运行守护进程呢?
更重要的是,如何告诉系统不要这样做?