Saya mencoba menjalankan skrip shell dari systemd. Script berjalan dengan baik dari baris perintah.
Script (runServer.sh), menjalankan proses Java dan terlihat seperti ini:
#!/bin/bash
java -jar -Dresources=/home/pruss/dev/ServerDeploy5-4.1/Server/resources/MyServer.jar "0" "Test"
Di dalam /usr/lib/systemd/system
(atau /lib/systemd/system/
di OS lain) saya telah membuat file layanan (myService.service):
[Unit]
Description=My Servers service
[Service]
ExecStart=/home/pruss/dev/ServerDeploy5-4.1/Server/runServer.sh
User=root
Type=oneshot
[Install]
WantedBy=multi-user.target
Hasil
Job for myService.service failed. See "systemctl status myService.service" and "journalctl -xn" for details.
Saya coba:
systemctl status myService.service
Loaded: loaded (/usr/lib/systemd/system/myService.service; disabled)
Active: failed (Result: exit-code) since Thu 2015-07-23 12:27:38 BST; 26s ago
Main PID: 28413 (code=exited, status=203/EXEC)