Ah, you must be a youngster … Back in my day, we couldn’t even afford the luxury of parsing massive log files; CPU power and storage speed just made it impractical.
What I’d do in this situation is to check for the last-modified timestamp of the log file, then act based on that - this has the added benefit of not killing the server mid-way through a media scan or other scheduled process, it’ll simply kill it
x hours after it’s completed the last thing it was doing.
Try something like this…
sFile=$(ls /var/log/jellyfin/jellyfin*.log | tail -1)
tFile=`stat -c "%Y" $sFile`
if [ $tIdle -gt $tDoze ]; then
echo "Server has been idle for $tIdle seconds, shutting down..."
shutdown -P 0
echo "Server has been idle for $tIdle seconds."
Change the value assigned to tDoze at the beginning to suit your taste; the sample is two hours.