18 lines
564 B
Bash
Raw Normal View History

2016-11-28 23:17:04 +01:00
#!/bin/sh
2016-12-04 15:30:05 +01:00
2016-12-04 14:58:40 +01:00
# periodically check if daemon is running
# if not:
# 1. kill former tail processes
# 2. start daemon and wait 5 seconds for startup of logging
# 3. tail new logfile
2016-12-04 14:35:16 +01:00
while true; do
2016-12-04 15:30:05 +01:00
pgrep raumsrvDaemon 1>/dev/null 2>&1 || {
echo "$(date "+%Y.%m.%d %H:%M:%S.000") Process missing in action. Starting or restarting raumsrvDaemon.";
pkill tail 2>/dev/null;
2016-12-04 14:58:40 +01:00
/opt/raumserver/raumsrvDaemon && sleep 5;
new_log=$(ls -t /opt/raumserver/logs/*.log 2>/dev/null | head -n 1);
[ -n "${new_log}" ] && tail -f $new_log &
2016-12-04 14:35:16 +01:00
}
sleep 5
done