Run a cron job to get the user agent list and send an email alert

Hi all,

I want to run the below command to get user agent list and send an email alert using cron job.

for ext in $(rasterisk -x 'sip show peers'|egrep "^[0-9]*/[0-9]*.*OK"|sed 's/^\([0-9]*\).*/\1/');do echo -ne "$ext\t";rasterisk -x "sip show peer $ext"|grep Useragent|cut -d ":" -f2;done

how this can be acheived.

That looks familiar :slight_smile:

if you don’t have mail then install mailutils . cron uses /bin/sh whose echo can’t do -ne so a bash script would look much like

#!/usr/env/ bash
for ext in $(/usr/sbin/rasterisk -x 'sip show peers'|egrep "^[0-9]*/[0-9]*.*OK"|sed 's/^\([0-9]*\).*/\1/')
do echo -ne "$ext\t";/usr/sbin/rasterisk -x "sip show peer $ext"|grep Useragent|cut -d ":" -f2
done|mail -s "my Stuff" [email protected]

and the cronjob as root
0 0 * * * /path/to/your/script.sh

Thanks dicko… :slight_smile:

where should I create this file ?

anywhere your crontab user can read and execute it from

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.