Thanks for the tip Dougie. Systemd does sound like the best option.
I've it set up to run as a systemd unit, and as best as I can tell it's running, but the only think it now does is write to the log file to say it has started and appears to do nothing else.
The script runs loops forever that includes sending notification mail with sstmp, checking network devices with nc, cpu temperature checks, and writing out to log files when issues occur. I'm forcing the issues it should detect for testing, but as a service the script no longer outputs anything (emails, log files) so something is not quite right. When it was initiated from a command line it was performing as expected.
The systemd config for it from /lib/systemd/system, built up from info I could gleam from my best guesses from reading
https://www.digitalocean.com/community/ ... unit-files, is as follows:
Code: Select all
[Unit]
Description=Network check script by Dave F
After=multi-user.target
[Service]
#Type=idle
Type=forking
PIDfile=/home/me/pingTest.sh
ExecStart=/home/me/pingTest.sh
Restart=on-always
RestartSec=5
[Timer]
#delay added to allow time for sstmp and networking to be 100% ready
OnStartupSec=30
[Install]
WantedBy=multi-user.target
Have I made the right choices? Any suggestions for hos to ensure my .sh script works as well as a systemd service as it does when executed from the command line?
Thanks in advance.