システム実行形式エラー

システム実行形式エラー

サービスとしてインストールするJavaファイルがあります。しかし、エラーが発生します。以下は私のファイルの内容とエラーです。私はDebian 8を使用しています。

[Unit]
Description=App1Manager
After=syslog.target

[Service]
ExecStart=/usr/bin/jsvc -user root -cp /usr/share/java/commons-daemon.jar:/usr/local/myapp/bin/Manager.jar -pidfile /var/run/app1manager.pid

Type=forking

[Install]
WantedBy=multi-user.target

次のいずれかの状況で、次のエラーが発生します。

SYSTEMD_LOG_LEVEL=debug /lib/systemd/system/myapp1 
SYSTEMD_LOG_LEVEL=debug /etc/init.d/myapp1 

/etc/init.d/myapp1: line 1: [Unit]: command not found
/etc/init.d/myapp1: line 6: [Service]: command not found
/etc/init.d/myapp1: line 7: -user: command not found
/etc/init.d/myapp1: line 10: [Install]: command not found


Aug 12 12:04:39 debian systemd[3903]: Failed at step EXEC spawning /etc/init.d/myapp1: Exec format error
-- Subject: Process /etc/init.d/myapp1 could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /etc/init.d/myapp1 could not be executed and failed.
--
-- The error number returned while executing this process is 8.
Aug 12 12:04:39 debian systemd[1]: myapp1.service: control process exited, code=exited status=203
Aug 12 12:04:39 debian systemd[1]: Failed to start (null).
-- Subject: Unit myapp1.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit myapp1.service has failed.
--
-- The result is failed.
Aug 12 12:04:39 debian systemd[1]: Unit myapp1.service entered failed state.

ベストアンサー1

systemd/systemファイル拡張子でインストールしてください.service。実行ビットを設定する必要はありません。 systemd形式のサービスファイルをインストールしないでください/etc/init.d/。これは以前のSysVinitスタイルのサービススクリプトに適用されます。

サービスを開始するには、systemctl start myapp1サービスがsystemdとして実装されているかSysVで実装されているかわからない場合に使用してくださいservice myapp1 start

Install起動時に[該当するセクションを提供]を有効にするには、を使用しますsystemctl enable myapp1

おすすめ記事