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.
dicko
(dicko)
2
That looks familiar
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…
where should I create this file ?
dicko
(dicko)
4
anywhere your crontab user can read and execute it from
system
(system)
Closed
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.