# Pager Alert

**URL:** <https://community.unix.com/t/pager-alert/284097>\
**Category:** Shell Programming and Scripting\
**Created:** [March 8, 2011, 1:27pm UTC](https://community.unix.com/t/pager-alert/284097 "2011-03-08T13:27:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mskalyani9](https://community.unix.com/letter_avatar/mskalyani9/32/5_5575768a8748004e209b776fc1b2916d.png) [@mskalyani9](https://community.unix.com/u/mskalyani9)\
**Post date:** [March 8, 2011, 1:27pm UTC](https://community.unix.com/t/pager-alert/284097/1 "2011-03-08T13:27:12Z")

</div>

I want to check the log file continoulsy and to send a page alert if i see specific message like Reached Max Connrctions . Please suggest how to do this through script  
DO i need to enable the cronjob to run the script evey 5 min or what is the best way

---

<div class="post-metadata">

**Author:** ![DGPickett](https://community.unix.com/letter_avatar/dgpickett/32/5_5575768a8748004e209b776fc1b2916d.png) [@DGPickett](https://community.unix.com/u/DGPickett)\
**Post date:** [March 8, 2011, 1:50pm UTC](https://community.unix.com/t/pager-alert/284097/2 "2011-03-08T13:50:10Z")

</div>

See man tail, -f option, much slicker way in than a timed poll, low latency, too. You can use grep to find the line number of the last hit, and tail after that line, if you want to restart it seamlessly after a hit. Maybe something like this, to continue after each hit:

```nohighlight
 
while tail -f +0$last_hit_line $log_file | grep -q 'your_patern'
do
 tail -f +0$last_hit_line $log_file | grep -n 'your_patern' | tail -1 | read last_hit_line x
 .
 .
 .
done

```

---

<div class="post-metadata">

**Author:** ![mskalyani9](https://community.unix.com/letter_avatar/mskalyani9/32/5_5575768a8748004e209b776fc1b2916d.png) [@mskalyani9](https://community.unix.com/u/mskalyani9)\
**Post date:** [March 8, 2011, 8:58pm UTC](https://community.unix.com/t/pager-alert/284097/3 "2011-03-08T20:58:44Z")

</div>

hi i need to monitor the log file and need to perform the series of steps as soon as i see some text .the below code is just greeping data .

---

<div class="post-metadata">

**Author:** ![rdcwayx](https://community.unix.com/letter_avatar/rdcwayx/32/5_5575768a8748004e209b776fc1b2916d.png) [@rdcwayx](https://community.unix.com/u/rdcwayx)\
**Post date:** [March 9, 2011, 1:29am UTC](https://community.unix.com/t/pager-alert/284097/4 "2011-03-09T01:29:58Z")

</div>

the rest gap is for self-study.

---

<div class="post-metadata">

**Author:** ![DGPickett](https://community.unix.com/letter_avatar/dgpickett/32/5_5575768a8748004e209b776fc1b2916d.png) [@DGPickett](https://community.unix.com/u/DGPickett)\
**Post date:** [March 14, 2011, 10:49am UTC](https://community.unix.com/t/pager-alert/284097/5 "2011-03-14T10:49:27Z")

</div>

Well, methods vary. Do whatever in the loop. I like:

```nohighlight
echo "Identifying message" | mailx -s "$(uname -n):Subject-topic" pager_email_address

```
