Email script malfunction everyday at midmight.

We have mikrotik RB4011iGS+ acting as our IKEv2 vpn server.
Routeros 6.49.13

I have setup script that runs every 5 seconds to scan the logs and then execute email notification to when ikev2 connection is established/disconnects.

Everything works great during the day but every night at 00:01 the script will malfunction and send up to 42 emails to the email address specified int he script.

:local servername "KKTOYOTA VPN"
:local adminaddress "test@test.com"
:local message1 "You have connected to KKTOYOTA network using VPN"
:local message2 "You have been disconnected from the KKTOYOTA network"
:local time [:system clock get time]
:local date [:system clock get date]

# Find all "acquired 10.0.0.3" error last 5s
:local loglist1 [:toarray [/log find  time>([/system clock get time] - 5s) message~"acquired 10.0.0.3"]]
:local loglist2 [:toarray [/log find  time>([/system clock get time] - 5s) message~"releasing address 10.0.0.3"]]

# for all error do
:foreach i in=$loglist1 do={

# find message
	:local logMessage [/log get $i message]
# find ip
	:local ip [:pick $logMessage 0 [:find $logMessage " "]]
# Send a message to the log	
	:log warning "IKE2 VPN - john connected - $date - $time"

/tool e-mail send to=$adminaddress subject="$servername" body="$message1
--------------------
Username - john
Date - $date
Time - $time
--------------------
"
}

# for all error do
:foreach i in=$loglist2 do={

# find message
	:local logMessage [/log get $i message]
# find ip
	:local ip [:pick $logMessage 0 [:find $logMessage " "]]
# Send a message to the log	
	:log warning "IKE2 VPN - john disconnected - $date - $time"

/tool e-mail send to=$adminaddress subject="$servername" body="$message2 
-------------------- 
Username - john
Date - $date
Time - $time
--------------------
"
}

I have noticed in /system/script/job that sometimes the job will get stuck and needs to be stop manually.
mklogs.JPG