CronJob for asterisk queue to reset + FreePBX

1

I am having problems with this script...It doesn't seem to work. Note: It sends email just fine.

#!/bin/bash

#Reset the queue every morning at 5:00AM PST
#v 1.1 changed email

#Email alert that queue has been reset
#

asterisk -rx 'queue reset stats'
SUBJECT="XXXXX"
EMAIL="XXXX@domain.com"
EMAILMESSAGE="Queue has been reset"
echo "$EMAILMESSAGE" | /bin/mail -s "$SUBJECT" "$EMAIL"

JoyIan Yee-Hernandez

Posted 2012-10-04T14:04:40.370

Reputation: 487

2does asterisk -rx 'queue reset stats' work when typed in the console? (assuming that's the line not working from your script). – m4573r – 2012-10-04T14:08:34.197

@m4573r Yes it does work manually typing on the console. – JoyIan Yee-Hernandez – 2012-10-05T12:01:16.753

So what's not working actually? Is it only when run by cron? Does it fail every time? Have you tried other schedules? Have you tried to run the script manually at the same time that your crontab would run it? – m4573r – 2012-10-05T12:16:08.440

@m4573r Ran the script manually and it worked...now this is really getting weird and interesting....the script is owned by root and the permissions seem to be fine...-rwxr-xr-x 1 root root Any inputs? – JoyIan Yee-Hernandez – 2012-10-09T14:47:59.743

Well, not really... You should be sure the script is executed, to see if that's the problem or if it comes from the asterisk. In case it does, you should try to log the result of the command see what's causing the error... – m4573r – 2012-10-09T14:52:41.127

Well I'm sure the script is executed since I get email everyday about the queue being reset. Not that old to scripting but can you advise? asterisk seems to be fine. – JoyIan Yee-Hernandez – 2012-10-09T14:59:45.457

try this: asterisk -rx 'queue reset stats' >>/path/to/home/log.txt 2>&1 instead of your normal command, and look ad the content of log.txt after the cronjob has been triggered. Of course you have to replace /path/to/home with the actual value ;) – m4573r – 2012-10-09T15:30:50.857

Tried it and it was empty....errrrrr – JoyIan Yee-Hernandez – 2012-10-09T15:33:59.310

I'm running out of ideas... Does the crontab belong to you or to root? – m4573r – 2012-10-09T15:37:14.780

No answers