Please help to write the script that should raise an alarm if the new logs will not come in the log file.
In other words i want to write a script which will monitor the log file continuously and will raise an alarm if the logs will not come after some time suppose 5 minutes.My boss asked me to do this so please help me, it is Urgent.
Are there timestamps in there so you know what is 5 minutes old? Do you see an entry in the log or can you use it in the script when the action is taken, that should cause such a log entry?
You can also try to copy (if you have enough free space) the actual log away, wait 5 mins, then diff it to the actual log and check the diff if there is the entry in it and if not, launch your alarm.
Hi Zaxxon,
No there are no time stamps in the log file.I think u donot understand my question the problem is the script will monitor the live log file and if new logs are not coming/generating in the file within some time suppose 5 minutes then the alarm should be raised.Hope u got it this time.I was thinking that script should contain a counter which will be incremented evry time some thing like that.
Just use cksum or get the size with "ls -l" or number of lines/characters with wc on the log file, write the result of one of those commands to a file in /tmp for example. Start the script every 5 mins and compare the actual result with the one taken 5 minutes before in the file in /tmp. If nothing changed just launch the alarm.
This is what I was looking for. Thanks for this, now the problem is that it is so hectic to start the script after every five minutes, Do you have any idea to start the script automatically without using the crontab command