最新記事

再起動時にExecStopPostを実行する
systemd

再起動時にExecStopPostを実行する

オペレーティングシステムの再起動時にExecStopPostのコマンドが実行されるようにサービスを正しく設定する方法。 my.service [Unit] Description=my.service After=syslog.target After=network.target After=my-service.mount ConditionFileNotEmpty=/opt/myService/myService.java [Service] User=UserName Group=UserGroup WorkingDirectory=/opt/myService OOMScoreAdjust=-100 Type=forking ExecStart=/usr/bin/java ./myService.java start TimeoutStartSec=90 ExecStopPost=/usr/bin/java ./myService.java stop TimeoutStopSec=30 Restart=on-failure RestartSec=60 [Install] WantedBy=multi-user.target

Admin

最初のソリューション
systemd

最初のソリューション

systemdが有効なシステムでシェルを起動するのと同等の方法は何ですか? sysinit/grub では、ルートファイルシステムをマウントしてカーネルにrw渡し、オプションで実行レベル 1 に設定します。init=/bin/bash systemd / bootdシステムには、ルート(luks、lvmなど)を正しくマウントするためのすべてのオプションがあり、インストールされていますが、カーネルに渡され、起動時に/sysroot「ルート切り替え」ステップで渡されることがわかります。init=/sysroot/bin/bash single失敗する。ドキュメントでinitの前に何が起こるべきか(後で発生した場合、シェルとしてのinitはプロセスを一時停止しませんか?)

Admin

Ubuntu 22.04で起動している間にpostgresqlデータベースが準備されるまでkea-dhcp4-serverを待つ方法は?
ubuntu
systemd

Ubuntu 22.04で起動している間にpostgresqlデータベースが準備されるまでkea-dhcp4-serverを待つ方法は?

私のkea-dhcp4-serverは私のpostgresqlデータベースに依存しています。再起動後、DHCP サーバーで次のエラーが発生します。 sudo systemctl status kea-dhcp4-server × kea-dhcp4-server.service - Kea IPv4 DHCP daemon Loaded: loaded (/lib/systemd/system/kea-dhcp4-server.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/kea-dhcp4-server.service.d └─override.conf Active: failed (Result: exit-code) since Sun 2024-02-11 17:09:18 UTC; 11min ago Docs: man:kea-dhcp4(8) Process: 1104 ExecStart=/usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf (code=exited, status=1/FAILURE) Main PID: 1104 (code=exited, status=1/FAILURE) CPU: 39ms Feb 11 17:09:18 ns1 systemd[1]: Started Kea IPv4 DHCP daemon. Feb 11 17:09:18 ns1 kea-dhcp4[1104]: 2024-02-11 17:09:18.166 ERROR [kea-dhcp4.dhcp4/1104.140666424032896] DHCP4_CONFIG_LOAD_FAIL configuration error using file: /etc/kea/kea-dhcp4.conf, reason: Unable to open database: connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection> Feb 11 17:09:18 ns1 kea-dhcp4[1104]: Is the server running on that host and accepting TCP/IP connections? Feb 11 17:09:18 ns1 kea-dhcp4[1104]: 2024-02-11 17:09:18.166 ERROR [kea-dhcp4.dhcp4/1104.140666424032896] DHCP4_INIT_FAIL failed to initialize Kea server: configuration error using file '/etc/kea/kea-dhcp4.conf': Unable to open database: connection to server at "localhost" (127.0.0.1), port 5432> Feb 11 17:09:18 ns1 kea-dhcp4[1104]: Is the server running on that host and accepting TCP/IP connections? Feb 11 17:09:18 ns1 systemd[1]: kea-dhcp4-server.service: Main process exited, code=exited, status=1/FAILURE Feb 11 17:09:18 ns1 systemd[1]: kea-dhcp4-server.service: Failed with result 'exit-code'. したがって、Postgresqlデータベースが後で開始されたか、まだ準備されていないようです。注:このkea-dhcp4-severサービスを手動で開始すると、すべてがうまく機能します。 kea-dhcp4-server.serviceを編集するときは、次のようにさまざまなオプションを試しました。 sudo systemctl edit kea-dhcp4-server Wants =、After =、およびRequires =を試しましたが、すべて成功しませんでした。 たぶんPostgres <==ネットワーク==> Dhcpサーバー間の循環依存関係もありますか? 私の質問は:Ubuntu 22.04で起動中にpostgresqlデータベースが準備されるまでkea-dhcp4-serverを待つようにするにはどうすればよいですか?

Admin

root以外のユーザーのログ設定を指定するには?
systemd
systemd-journald

root以外のユーザーのログ設定を指定するには?

ルート以外のユーザーとして自動的に実行されるサービスがたくさんあります。許容される最大ファイルサイズを制限するために/etc/systemd/journald.confを変更しましたが、root以外のユーザーとして実行されるシステムサービスでは機能しません。 root以外のユーザーとして実行されているすべてのサービスに対してログエントリをXMBに制限するようにシステムに指示するにはどうすればよいですか?

Admin

エラー: 'user_jvm_args.txt'を開けません。
systemd
permissions
services
java
minecraft

エラー: 'user_jvm_args.txt'を開けません。

bashスクリプトをサービスにしたのは今回が初めてで、Java引数のテキストファイル(user_jvm_args.txt)を開くことができなかったため、サービスが失敗したというエラーが発生しました。ある種の権限問題があると思いますが、迷っています。より良くなって学びようと努力すれば何でも役に立ちます。ありがとうございます! サービスファイルは次のとおりです。 [Service] ExecStart=/home/ethan/ATM9-Server/run.sh run.sh bashスクリプトは次のとおりです。 #!/usr/bin/env sh java @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.20.1-47.1.3/unix_args.txt "$@" 以下は、run.shスクリプトと同じフォルダーにあるuser_jvm_args.txtファイルです。 # Xmx and Xms set the maximum and minimum RAM usage, respectively. # They can take any number, followed by an M or a G. # M means Megabyte, G means Gigabyte. # For example, to set the maximum to 3GB: -Xmx3G # To set the minimum to 2.5GB: -Xms2500M # A good default for a modded server is 4GB. -Xms1G -Xmx10G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 ほとんどはデフォルトで、私が変更したのは-Xmsと-Xmxだけです。 ログに示すように発生したエラーは次のとおりです。 Nov 03 15:44:43 ATM9-Server-Temp systemd[1]: Started run.service. Nov 03 15:44:43 ATM9-Server-Temp run.sh[12480]: Error: could not open `user_jvm_args.txt' Nov 03 15:44:43 ATM9-Server-Temp systemd[1]: run.service: Main process exited, code=exited, status=1/FAILURE Nov 03 15:44:43 ATM9-Server-Temp systemd[1]: run.service: Failed with result 'exit-code'.

Admin

マウントされた(コピーされた)ドライブでLinuxホスト名を変更する方法
systemd
hostname

マウントされた(コピーされた)ドライブでLinuxホスト名を変更する方法

ddを使用してヘッドレスUbuntu 22LTSサーバーをバックアップドライブにコピーし、それを同じ関連設定でバックアップサーバーとして展開したいと思います。 バックアップハードウェアから起動する前にコピーされたドライブのホスト名を変更する正しい方法は何ですか? システムがヘッドレスで実行されているため、起動後にコンソールにログインして対話型設定を実行することはできません。ネットワークにインポートしてsshでログインする必要がありますが、当然実行しているサーバーとの競合を避ける必要があります。 以前はマウントされたドライブで/etc/hostnameを変更しましたが、システムでは状況が異なる場合があります。

Admin

podmangenerateを使用して生成されたsystemdサービスを有効にできないのはなぜですか?
systemd
container
podman
docker-compose

podmangenerateを使用して生成されたsystemdサービスを有効にできないのはなぜですか?

この設定を考慮すると: --- version "3" services: wireguard: image: "lscr.io/linuxserver/wireguard" container_name: "wireguard" cap_add: - "NET_ADMIN" environment: PUID: "1000" PGID: "1000" TZ: "Europe/London" ports: - "8080:8080" - "6881:6881" - "6881:6881/udp" volumes: - "./wireguard/config:/config" - "/lib/modules:/lib/modules" sysctls: - "net.ipv4.conf.all.src_valid_mark=1" privileged: true qbittorrent: image: "lscr.io/linuxserver/qbittorrent" container_name: "qbittorrent" network_mode: "service:wireguard" environment: PUID: "1000" PGID: "1000" TZ: "Europe/London" WEBUI_PORT: "8080" volumes: - "./qbittorrent/config:/config" - "./qbittorrent/downloads:/downloads" そのシステムサービスを起動および/または有効にできないのはなぜですか?私が実行したコマンドは次のとおりです。 sudo loginctl enable-linger myuser podman-compose up -d podman stop -a podman generate systemd --new --files --name wireguard podman generate systemd --new --files --name qbittorrent podman system prune # pressed 'y' mkdir -p $HOME/.config/systemd/user sudo mv -v container-wireguard.service /etc/systemd/system/ mv -v container-qbittorrent.service $HOME/.config/systemd/user/ sudo systemctl daemon-reload systemctl --user daemon-reload sudo systemctl start container-wireguard.service systemctl --user start container-qbittorrent.service 結果cat container-wireguard.service: # container-wireguard.service # autogenerated by Podman 4.3.1 # Thu Sep 14 14:07:16 CEST 2023 [Unit] Description=Podman container-wireguard.service Documentation=man:podman-generate-systemd(1) Wants=network-online.target After=network-online.target RequiresMountsFor=%t/containers [Service] Environment=PODMAN_SYSTEMD_UNIT=%n Restart=on-failure TimeoutStopSec=70 ExecStartPre=/bin/rm \ -f %t/%n.ctr-id ExecStart=/usr/bin/podman run \ --cidfile=%t/%n.ctr-id \ --cgroups=no-conmon \ --rm \ --sdnotify=conmon \ --replace \ --name=wireguard \ -d \ --label io.podman.compose.config-hash=f7ac51a86e7d72fe8967478b47a2cd9a2e53d672610c3caa797afe25d62e2dfd \ --label io.podman.compose.project=torrent \ --label io.podman.compose.version=1.0.6 \ --label [email protected] \ --label com.docker.compose.project=torrent \ --label com.docker.compose.project.working_dir=/home/myuser/podman/torrent \ --label com.docker.compose.project.config_files=docker-compose.yml \ --label com.docker.compose.container-number=1 \ --label com.docker.compose.service=wireguard \ --cap-add NET_ADMIN \ -e PUID=1000 \ -e PGID=1000 \ -e TZ=Europe/London \ -e ALLOWEDIPS=0.0.0.0/0 \ -e LOG_CONFS=True \ -v /home/myuser/podman/torrent/wireguard/config:/config:z \ -v /lib/modules:/lib/modules:z \ --net torrent_default \ --network-alias wireguard \ -p 8080:8080 \ -p 6881:6881 \ -p 6881:6881/udp \ --sysctl net.ipv4.conf.all.src_valid_mark=1 \ --privileged linuxserver/wireguard:latest ExecStop=/usr/bin/podman stop \ --ignore -t 10 \ --cidfile=%t/%n.ctr-id ExecStopPost=/usr/bin/podman rm \ -f \ --ignore -t 10 \ --cidfile=%t/%n.ctr-id Type=notify NotifyAccess=all [Install] WantedBy=default.target 結果sudo systemctl status container-wireguard.service: × container-wireguard.service - Podman container-wireguard.service Loaded: loaded (/etc/systemd/system/container-wireguard.service; disabled; preset: enabled) Active: failed (Result: exit-code) since Thu 2023-09-14 14:18:06 CEST; 26min ago Docs: man:podman-generate-systemd(1) Main PID: 4500 (code=exited, status=125) CPU: 52ms Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Scheduled restart job, restart counter is at 5. Sep 14 14:18:06 homeserver systemd[1]: Stopped container-wireguard.service - Podman container-wireguard.service. Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Start request repeated too quickly. Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Failed with result 'exit-code'. Sep 14 14:18:06 homeserver systemd[1]: Failed to start container-wireguard.service - Podman container-wireguard.service. 結果journalctl -xeu container-wireguard.service: Sep 14 14:18:05 homeserver systemd[1]: Failed to start container-wireguard.service - Podman container-wireguard.service. ░░ Subject: A start job for unit container-wireguard.service has failed ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A start job for unit container-wireguard.service has finished with a failure. ░░ ░░ The job identifier is 873 and the job result is failed. Sep 14 14:18:05 homeserver systemd[1]: container-wireguard.service: Scheduled restart job, restart counter is at 3. ░░ Subject: Automatic restarting of a unit has been scheduled ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ Automatic restarting of the unit container-wireguard.service has been scheduled, as the result for ░░ the configured Restart= setting for the unit. Sep 14 14:18:05 homeserver systemd[1]: Stopped container-wireguard.service - Podman container-wireguard.service. ░░ Subject: A stop job for unit container-wireguard.service has finished ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A stop job for unit container-wireguard.service has finished. ░░ ░░ The job identifier is 987 and the job result is done. Sep 14 14:18:05 homeserver systemd[1]: Starting container-wireguard.service - Podman container-wireguard.service... ░░ Subject: A start job for unit container-wireguard.service has begun execution ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A start job for unit container-wireguard.service has begun execution. ░░ ░░ The job identifier is 987. Sep 14 14:18:05 homeserver podman[4458]: Error: unable to find network with name or ID torrent_default: network not found Sep 14 14:18:05 homeserver systemd[1]: container-wireguard.service: Main process exited, code=exited, status=125/n/a ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ An ExecStart= process belonging to unit container-wireguard.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 125. Sep 14 14:18:06 homeserver podman[4476]: Error: reading CIDFile: open /run/container-wireguard.service.ctr-id: no such file or directory Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Control process exited, code=exited, status=125/n/a ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ An ExecStopPost= process belonging to unit container-wireguard.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 125. Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Failed with result 'exit-code'. ░░ Subject: Unit failed ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ The unit container-wireguard.service has entered the 'failed' state with result 'exit-code'. Sep 14 14:18:06 homeserver systemd[1]: Failed to start container-wireguard.service - Podman container-wireguard.service. ░░ Subject: A start job for unit container-wireguard.service has failed ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A start job for unit container-wireguard.service has finished with a failure. ░░ ░░ The job identifier is 987 and the job result is failed. Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Scheduled restart job, restart counter is at 4. ░░ Subject: Automatic restarting of a unit has been scheduled ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ Automatic restarting of the unit container-wireguard.service has been scheduled, as the result for ░░ the configured Restart= setting for the unit. Sep 14 14:18:06 homeserver systemd[1]: Stopped container-wireguard.service - Podman container-wireguard.service. ░░ Subject: A stop job for unit container-wireguard.service has finished ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A stop job for unit container-wireguard.service has finished. ░░ ░░ The job identifier is 1101 and the job result is done. Sep 14 14:18:06 homeserver systemd[1]: Starting container-wireguard.service - Podman container-wireguard.service... ░░ Subject: A start job for unit container-wireguard.service has begun execution ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A start job for unit container-wireguard.service has begun execution. ░░ ░░ The job identifier is 1101. Sep 14 14:18:06 homeserver podman[4500]: Error: unable to find network with name or ID torrent_default: network not found Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Main process exited, code=exited, status=125/n/a ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ An ExecStart= process belonging to unit container-wireguard.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 125. Sep 14 14:18:06 homeserver podman[4519]: Error: reading CIDFile: open /run/container-wireguard.service.ctr-id: no such file or directory Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Control process exited, code=exited, status=125/n/a ░░ Subject: Unit process exited ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ An ExecStopPost= process belonging to unit container-wireguard.service has exited. ░░ ░░ The process' exit code is 'exited' and its exit status is 125. Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Failed with result 'exit-code'. ░░ Subject: Unit failed ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ The unit container-wireguard.service has entered the 'failed' state with result 'exit-code'. Sep 14 14:18:06 homeserver systemd[1]: Failed to start container-wireguard.service - Podman container-wireguard.service. ░░ Subject: A start job for unit container-wireguard.service has failed ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A start job for unit container-wireguard.service has finished with a failure. ░░ ░░ The job identifier is 1101 and the job result is failed. Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Scheduled restart job, restart counter is at 5. ░░ Subject: Automatic restarting of a unit has been scheduled ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ Automatic restarting of the unit container-wireguard.service has been scheduled, as the result for ░░ the configured Restart= setting for the unit. Sep 14 14:18:06 homeserver systemd[1]: Stopped container-wireguard.service - Podman container-wireguard.service. ░░ Subject: A stop job for unit container-wireguard.service has finished ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A stop job for unit container-wireguard.service has finished. ░░ ░░ The job identifier is 1215 and the job result is done. Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Start request repeated too quickly. Sep 14 14:18:06 homeserver systemd[1]: container-wireguard.service: Failed with result 'exit-code'. ░░ Subject: Unit failed ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ The unit container-wireguard.service has entered the 'failed' state with result 'exit-code'. Sep 14 14:18:06 homeserver systemd[1]: Failed to start container-wireguard.service - Podman container-wireguard.service. ░░ Subject: A start job for unit container-wireguard.service has failed ░░ Defined-By: systemd ░░ Support: http://www.ubuntu.com/support ░░ ░░ A start job for unit container-wireguard.service has finished with a failure. ░░ ░░ The job identifier is 1215 and the job result is failed. 結果podman ps -a: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 00b4f3b11446 docker.io/linuxserver/wireguard:latest 40 minutes ago Created 0.0.0.0:8080->8080/tcp, 0.0.0.0:6881->6881/tcp, 0.0.0.0:8083-8084->3000-3001/tcp, 0.0.0.0:6881->6881/udp wireguard 12d5c92f0c1e docker.io/linuxserver/qbittorrent:latest 40 minutes ago Created 0.0.0.0:8080->8080/tcp, 0.0.0.0:6881->6881/tcp, 0.0.0.0:8083-8084->3000-3001/tcp, 0.0.0.0:6881->6881/udp qbittorrent 結果podman network ls: ... a11919c606c3 torrent_default bridge どんな助けでも大変感謝します。

Admin

エラーメッセージ
systemd

エラーメッセージ

依存関係エラーが発生するのはなぜですか?私は何を実行するかを指定せず、以前に実行する項目のみを指定しました。しかし、依存関係のサイクルがあります。 systemdにサービスを追加しようとしましたが、ソートエラーが発生しました。 エラーメッセージ から抜粋/var/log/boot.log [ SKIP ] Ordering cycle found, skipping local-fs-pre.target [ SKIP ] Ordering cycle found, skipping systemd-ask-password-plymouth.path [ SKIP ] Ordering cycle found, skipping paths.target [ SKIP ] Ordering cycle found, skipping cryptsetup.target [ SKIP ] Ordering cycle found, skipping local-fs.target [ SKIP ] Ordering cycle found, skipping local-fs-pre.target [ SKIP ] Ordering cycle found, skipping systemd-ask-password-plymouth.path [ SKIP ] Ordering cycle found, skipping cryptsetup.target [ SKIP ] Ordering cycle found, skipping systemd-pcrphase-sysinit.service [ SKIP ] Ordering cycle found, skipping local-fs.target [ SKIP ] Ordering cycle found, skipping local-fs-pre.target [ SKIP ] Ordering cycle found, skipping plymouth-start.service [ SKIP ] Ordering cycle found, skipping cryptsetup.target [ SKIP ] Ordering cycle found, skipping local-fs.target [ SKIP ] Ordering cycle found, skipping local-fs-pre.target [ SKIP ] Ordering cycle found, skipping systemd-ask-password-plymouth.path [ SKIP ] Ordering cycle found, skipping cryptsetup.target [ OK ] Finished plymouth-read-write.service - Tell Plymouth To Write Out Runtime Data. [ OK ] Finished systemd-tmpfiles-setup.service - Create Volatile Files and Directories. Starting systemd-timesyncd.service - Network Time Synchronization... Starting systemd-update-utmp.service - Record System Boot/Shutdown in UTMP... [ SKIP ] Ordering cycle found, skipping systemd-ask-password-plymouth.path [ SKIP ] Ordering cycle found, skipping cryptsetup.target サービスファイル cat ./remove-bad-yoga-keyboard-device.service [Unit] Description=disable the internal keyboard Before=keyboard-setup.service Before=console-setup.service Before=systemd-user-sessions.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/local/remove-bad-yoga-keyboard-device WorkingDirectory=/local StandardOutput=inherit StandardError=inherit User=root [Install] WantedBy=multi-user.target インストーラ cat setup-disable-yoga-keyboard #!/bin/bash cwd="$(pwd)" cd "$(dirname "$(realpath "$0")")" this_dir="$(pwd)" mkdir -p /local cd /local cp -t . "${this_dir}"/remove-bad-yoga-keyboard-device cd /etc/systemd/system cp -t . "${this_dir}"/remove-bad-yoga-keyboard-device.service systemctl daemon-reload systemctl enable remove-bad-yoga-keyboard-device.service systemd-analyzeディスプレイを使用した一部のプレイでは、競合が表示されますshutdown.target。しかし、この目標を分析してみると、すべてと衝突することがわかりました。私の考えでは、シャットダウンが特別であり、アナライザがこれを理解していないようです。それはshutdown.target問題ではありません。これは私に何かという質問を残します。 もう少し試した後、ルールを削除してパスし、Before=keyboard-setup.serviceエラーsystemd-analyze verifyなしで起動しました。 しかし、依存関係エラーが発生するのはなぜですか?私は何を実行するかを指定せず、以前に実行する項目のみを指定しました。しかし、依存関係のサイクルがあります。 オペレーティングシステム:Debian GNU / Linux 12(bookworm)は /localルートパーティションのディレクトリです。

Admin

特定のシステムサービスでシステムサービスを開始/終了しますか?
linux
ubuntu
systemd
services
systemd-unit

特定のシステムサービスでシステムサービスを開始/終了しますか?

私はシステムを持っています: サービス1.サービス サービス2.サービス サービス3.サービス service1.service は次のようになります。 [Unit] Wants=service2.service service3.service After=service2.service service3.service [Service] ExecStart=/var/scripts/script.sh [Install] WantedBy=multi-user.target このservice1.serviceは何をすべきかをします。it brings up services 2 and 3 before ExecStartこれは私が必要とする仕事の50%です。残りの50%は終了、終了、またはservice2他の終了時にservice3終了します。service1systemctl stop service1SIGKILL このタスクをどのように構成service2/service3実行する必要がありますか?

Admin

debian
ubuntu
systemd

"systemd-tmpfiles --clean"の問題

systemd-tmpfilesを使ってディレクトリを整理したいと思います。 私のUbuntu 22サーバーでmantmpfiles.d次の例が表示されます。 # Files created and modified, and directories accessed more than # an hour ago in "/tmp/foo/bar", are subject to time-based cleanup. d /tmp/foo/bar - - - - bmA:1h - これをテンプレートとして使用して、次のクリーンアップ仕様を作成しました。 d /var/mytmp 1777 root root - bmA:1h - ただし、次のコマンドを実行するとエラーが発生します。 systemd-tmpfiles --clean /etc/tmpfiles.d/tmp.conf /etc/tmpfiles.d/tmp.conf:6: d lines don't take argument fields, ignoring. マニュアルページに誤字があるようで仕様を次に変更しました。 d /var/mytmp 1777 root root bmA:1h これはうまくいくようです。 その後、Debian 11.5(雄牛の目)を実行しているバナナパイで同じ行を試しましたが、次のような結果が得られました。 /etc/tmpfiles.d/tmp.conf:11: Invalid age 'bmA:30d' tmpfiles.d のマニュアルページは Debian で少し異なって見えますが、年齢仕様は Ubuntu 22 のように特定の点で制限されていないようです. 目標を達成する年齢をどのように指定しますか?

Admin

Dバス監視はコマンドラインで機能しますが、システムサービスでは機能しません。
systemd
d-bus

Dバス監視はコマンドラインで機能しますが、システムサービスでは機能しません。

ModemManagerを使用してSMSメッセージを読み取るbashスクリプトを作成しましたmmcli。ほとんどの場合、コマンドラインでは正常に動作しますが、システムサービスで起動すると機能しません。 私はこの行が問題の核心であることをすぐに見つけました。 /usr/bin/gdbus monitor --system --dest org.freedesktop.ModemManager1 コマンドラインから起動すると、USBモデムはSMSメッセージを受信するたびに1行を印刷します。これが私が期待したものであり、私に必要なものです。 出力例(注釈付き): # at the start Monitoring signals from all objects owned by org.freedesktop.ModemManager1 The name org.freedesktop.ModemManager1 is owned by :1.5 # when a message arrives /org/freedesktop/ModemManager1/Modem/0: org.freedesktop.DBus.Properties.PropertiesChanged ('org.freedesktop.ModemManager1.Modem.Messaging', {'Messages': <[objectpath '/org/freedesktop/ModemManager1/SMS/19']>}, @as []) /org/freedesktop/ModemManager1/Modem/0: org.freedesktop.ModemManager1.Modem.Messaging.Added (objectpath '/org/freedesktop/ModemManager1/SMS/19', true) サービスファイルを追加した後にsystemdサービスと同じスクリプトを起動すると、同じ操作は実行されません。gdbus同じ2行を出力することから始めます。監視というのですがgdbusそうではありません。テキストメッセージが続きましたが、目立たなかった。 サービスが実行されているか、スクリプトがgdbus実行されているか、同じユーザーIDを確認しました。 rootで実行しても役に立ちません。 コマンドラインとsystemdの違いは何ですか?どうすれば解決できますか? サービスファイル - 特別なものはありません。 [Unit] Description=Read incoming SMS messages After=network-online.target [Service] Type=exec User=smsuser Environment=LANG=en_US.UTF-8 ExecStart=/bin/bash /opt/sms/sms_read_service ModemNameArg Restart=on-failure [Install] WantedBy=multi-user.target 修正する: 私はそれを働かせました: # shortened for brevity busctl --system monitor ... --match type='signal',interface='...',member='...'") ただし、rootユーザーとしてのみ可能です。これはD-Busセキュリティポリシーで説明できるようです。 使用法の違いを引き起こす原因が何であるかgdbusに関する質問が残っています。

Admin