
私は以下の内容の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
私はルート権限を持つログイン状態です。
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'.
OSはRedHat8.2です