PDA

View Full Version : Cron not working in pika warp v2 ?



carlostico
04-05-12, 11:52 PM
I have been trying to run the sms to email script with no luck.

#!/bin/sh
echo "Running SMS cron"
# fetch messages - port 1 only
asterisk -rx "gsm fetch sms 1"
sleep 1
if [ -d /var/spool/asterisk/smsin ] ; then
cd /var/spool/asterisk/smsin
TEST=`ls *.sms`
if [ "$TEST" != "" ] ; then
for file in $TEST ; do
echo "Message found."
echo "$file"
# create mail
echo "From: Warp" > msg
echo "Subject: SMS message received" >> msg
echo >> msg
echo `date` >> msg
echo >> msg
cat $file >> msg
cat msg | sendmail username@mydomain.com
# remove the file so it is not sent twice
rm $file
done
else
echo "- No messages"
exit 0
fi
fi

The scrip runs perfect manually but when I tried with cron i got nothing.

Any ideas ?

Did something changed betwen V1 and V2 regardin this in cron or in gsm fetch because this is working flawesly on V1 ?

carlostico
04-06-12, 09:01 AM
Seem that the paths have changed and we have to include the actual Path in the bash

so just insert this after the shebangs

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

That will do the trick