I am trying to have services restart when a certain text output appears in systemctl status or a log file.
The full line in this example is:
Aug 27 01:05:16 SSD plexdrive410[1321]: [USR/LOCAL/BIN/PLEXDRIVE410] [2018-08-27 01:05] WARNING: Could not update/save object 4PASA4U3Gj8mTvllAAIgEqHdMFHER3q (screens.jpg)
The key words will always contain
WARNING: Could not update/save object
I have tried searching for an answer but was unable to find one, I appreciate any pointers!
Updated script I am trying to use:
Thank you for the write up and explanation. The first time it restarts SERVICE repeatedly.
I then added sleep 30, however each time the script runs it will restart the service file regardless of the line containing the wanted regex.
The script as such is:
Could not update/save object
lines are getting sent to the log when you restart. Sleeping won't help, since those log lines will still be waiting. I'd need to see the log lines after an auto-restart to give further advice. – Matthew Cline Aug 28 '18 at 19:57Could not update\/save object
This solves the challenge! Thank you Matthew.
– askef Aug 28 '18 at 20:23