Strange for me:
I have a bash script (cams_record.sh) which will take care of recordings of my ipcams. This script should be started by systemd (cams_record.service). That service file should take care of the bash script (which should always be running).
So I created a service file, but when I start the systemd service: it starts/runs which is showed by the systemd status check. However when I check the status again then systemd service has been stopped. What might be wrong (f.i. in the service file)?
Below the output of starting cams_record.service and then twice the output of the status:
systemctl start cams_record
systemctl status cams_record
. cams_record.service - record ipcams
Loaded: loaded (/lib/systemd/system/cams_record.service; enabled; vendor preset: enabled)
Active: active (running) since wo 2017-11-01 11:03:53 +03; 39ms ago
Main PID: 22904 (bash)
CGroup: /system.slice/cams_record.service
??22904 /bin/bash /media/USB2/movie/cams/cams_record.sh
??22912 /bin/bash /media/USB2/movie/cams/cams_record.sh
??22913 ps -ax
??22914 grep [f]fmpeg
??22915 grep rtsp://192.168.2.21:554/live/ch00_0
??22916 grep \-t 3600
nov 01 11:03:53 Shuttle systemd[1]: Started record ipcams.
systemctl status cams_record
. cams_record.service - record ipcams
Loaded: loaded (/lib/systemd/system/cams_record.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since wo 2017-11-01 11:03:55 +03; 5s ago
Process: 22988 ExecStart=/bin/bash /media/USB2/movie/cams/cams_record.sh (code=exited, status=1/FAILURE)
Main PID: 22988 (code=exited, status=1/FAILURE)
nov 01 11:03:55 Shuttle systemd[1]: cams_record.service: Unit entered failed state.
nov 01 11:03:55 Shuttle systemd[1]: cams_record.service: Failed with result 'exit-code'.
nov 01 11:03:55 Shuttle systemd[1]: cams_record.service: Service hold-off time over, scheduling restart.
nov 01 11:03:55 Shuttle systemd[1]: Stopped record ipcams.
nov 01 11:03:55 Shuttle systemd[1]: cams_record.service: Start request repeated too quickly.
nov 01 11:03:55 Shuttle systemd[1]: Failed to start record ipcams.
The content of the used service file is:
[Unit]
Description=record ipcams
After=network.target
Requires=network.target
RequiresMountsFor=/media/USB2
[Service]
Type=forking
WorkingDirectory=/media/USB2/movie/cams
ExecStart=/media/USB2/movie/cams/cams_record.sh
RemainAfterExit=yes
SyslogIdentifier=cams_record
[Install]
WantedBy=multi-user.target