啟用單元失敗:無效參數 systemctl enable .service

啟用單元失敗:無效參數 systemctl enable .service

我製作了一個startup_test.sh,其中包含以下內容

cd /home/xyz/Desktop/
gnome-terminal -e "bash -c ./efg"

#desktop 資料夾包含一個名為 的可執行檔efg

如果我gnome-terminal -e "bash -c ./efg"在終端中運行它就可以正常工作。打開一個新終端,程式運行efg正確。startup_test.sh


我的登入帳號具有 root 權限。

chmod +x startup_test.sh
cp startup_test.sh /usr/sbin/

我的startup_test.service有以下內容:

[Unit]
Description=ABC
[Install]
WantedBy=multi-user.target

[Service]
ExecStart=/usr/sbin/startup_test.sh
WorkingDirectory=/home/xyz/Desktop/startup
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n

startup_test.service被放置在/etc/systemd/system資料夾中。

現在命令

systemctl daemon-reload

正在運行。無輸出。

現在該命令systemctl enable startup_test.service給出以下輸出:

Failed to enable unit : Invalid argument

出現上述輸出的原因是什麼。

該命令systemctl start startup_test.service沒有給出任何輸出。

此指令systemctl status startup_test.service給出:

startup_test.service - ABC
   Loaded: loaded (/etc/systemd/system/startup_test.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2024-02-19 12:09:20 IST; 2min 55s ago
  Process: 32531 ExecStart=/usr/sbin/startup_test.sh (code=exited, status=203/EXEC)
 Main PID: 32531 (code=exited, status=203/EXEC)

Feb 19 12:09:20 localhost.localdomain systemd[1]: Started ABC.
Feb 19 12:09:20 localhost.localdomain systemd[1]: startup_test.service: Main process exited, code=exited, status=203/EXEC
Feb 19 12:09:20 localhost.localdomain systemd[1]: startup_test.service: Failed with result 'exit-code'.

作業系統是redhat 8.2

相關內容