Agent Auto log-off script for Asterisk

Many times an Agent will forget to logoff. This can cause call routing, payroll, and queue statistic problems with Asterisk. With a handy BASH script it is easy to log all the agents out the queues automatically. Below is the shell script and an example of the crontab entry for execution at 6:00 PM every day.



Written by mattb in: Asterisk,Scripts | Tags: , , ,


  • Thank you for the script!
    Seems to work. Putting it production for a client tonight

    Comment | January 30, 2018
  • mattb

    Thank you. Sorry for the slow response, I started a new job supporting developers and there are many core systems out of date!

    Comment | March 24, 2018
  • Bart

    Using FreeBPX 13 and Grandstream phones with BLF Busy Light Field to show LED indicator on the phone when agent is logged in. With these modifications the BLF is reset as well as an email is sent:


    LOGGEDIN=$(/usr/sbin/asterisk -rx “queue show” | /bin/grep -o ‘Local[^ ]*’)
    EXT=$(/usr/sbin/asterisk -rx “queue show” | /bin/grep -o ‘Local/…’ | cut -c7-9)

    for i in $LOGGEDIN

    /usr/sbin/asterisk -rx “queue remove member $i from 555”
    echo “$i removed”
    echo ‘==========’

    for j in $EXT

    /usr/sbin/asterisk -rx “devstate change Custom:QUEUE$j*555 NOT_INUSE”
    mail -s “Agent $j logged off by script” < /dev/null "emailaddress@domain.com"


    Comment | April 20, 2018

RSS feed for comments on this post. TrackBack URL

Leave a comment