It works fine on slackware, but not on fedora, not too sure why. You're welcome to use this if you want.
---- script
#!/bin/bash
# must be running asterisk as a user for this to work 'out of the box'
# cp restart_asterisk.sh /usr/sbin
# chown root.bin /usr/sbin/restart_asterisk.sh (or wheel or whatever, i run it as root)
# chmod +x /usr/sbin/restart_asterisk
# # then add to cron
# #crontab -e # # # this is to stop and start asterisk daily at 4:20am
# 20 4 * * * /usr/sbin/restart_asterisk.sh | mail root
# Variables
# user settings SU="/bin/su" SUUSER="asterisk" USEROPT="-c /usr/sbin/safe_asterisk"
# asterisk specific SAFEAST="/usr/sbin/safe_asterisk" ASTERISK="/usr/sbin/asterisk" PIDFILE="/var/run/asterisk/asterisk.pid"
# nothing to edit here..
if [ -f $SAFEAST ]; then
if [ -x !$SAFEAST ]; then
echo ""
echo "no asterisk to be run ... wussup"
# put mail thing here exit 1
fi
else
echo ""
echo "no asterisk to be run ... wussup"
# put mail thing here
exit 1
fi
if [ -f $ASTERISK ]; then #checks for pidfile existence
if [ -x $ASTERISK ]; then
if [ -f $PIDFILE ]; then
echo ""
echo -n "stopping and restarting asterisk:"
# stop asterisk
# figure out why that can't be a variable.. $ASTERISK -rx "stop now"
# make sure the pidfile disappears
while [ -f $PIDFILE ]; do
wait
done
# start asterisk
$SU $SUUSER $USEROPT echo -n " successfull"
echo ""
exit 0
else
$SU $SUUSER $USEROPT
echo ""
echo -n "starting asterisk:"
echo -n " successfull"
echo ""
exit 0
fi
else
echo "asterisk not executable"
exit 1;
fi
else
echo "no asterisk executable .. fix things"
exit 1
fi
-- end script
Neil Cherry wrote:
Andrew Edmond wrote:
Asterisk Community --
I'm looking for a way to gracefully shutdown asterisk at least once a
day and bring it back online. I'm using Gentoo Linux and using
safe_asterisk from /etc/init.d/asterisk.
Anybody have a handy CLI/crontab script that accomplishes this?
Andrew
------------------------------------------------------------------------
_______________________________________________ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
How about putting this in cron, as root type crontab -e and then add the following:
# reload asterisk every day at midnight exactly $00 00 * * * /etc/init.d/asterisk stop ; sleep 2 ; /etc/init.d/asterisk start
_______________________________________________ Asterisk-Users mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-users To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
