Summary:ASTERISK-08277: /etc/init.d/asterisk and/or safe_asterisk breaks cron/anacron (Debian)
Reporter:Matt King, M.A. Oxon. (kebl0155)Labels:
Date Opened:2006-12-04 17:44:41.000-0600Date Closed:2011-06-07 14:07:22
Versions:Frequency of

This is probably an easy fix for someone with better shell scripting than me.

To increase reliability at a customer's site, we need to stop and start asterisk at midnight each night when the call centre is not in use.  We're running a cron job for this, however the /etc/init.d/asterisk script leaves a defunct process which prevents all other cron.daily tasks from completing.

The defunct process also prevents running of cron.daily on subsequent days (as cron/anacron thinks it's still running from the previous attempt).


We're using the Debian init.d script from src/contrib/init.d.

We have in /etc/cron.daily/astrestart

test -x /etc/init.d/asterisk || exit 0
/etc/init.d/asterisk stop
/etc/init.d/asterisk start
The defunct process is left behind by the /etc/init.d/asterisk start.

I think it has something to do with safe_asterisk not terminating...
Comments:By: Jason Parker (jparker) 2006-12-04 18:06:26.000-0600

Background your jobs.


By: Matt King, M.A. Oxon. (kebl0155) 2006-12-05 04:49:37.000-0600

Sorry to reopen - do you mean with

/etc/init.d/asterisk start &

or (inside the init.d script)

safe_asterisk &

because I tried both of these and had the same problem.

By: Jason Parker (jparker) 2006-12-05 10:46:48.000-0600

You also need to redirect stdout and stderr to /dev/null - something like

/etc/init.d/asterisk restart 2>&1 /dev/null

This should be explained in `man 5 crontab`.

This isn't a bug in asterisk, safe_asterisk, the init script, or even cron.  Closing...again

By: Matt King, M.A. Oxon. (kebl0155) 2006-12-05 13:39:18.000-0600

Qwell, I hope you won't be angry with me for reopening this.

I checked the man pages for cron, crontab, anacron, anacrontab and run-parts. There was no mention of this problem, let alone a solution.  I agree whole heartedly that there ought to be.

Just in case some other fool ends up running into similiar trouble, and has as little luck as I did trying to find the solution online, on the IRC channel, or the bugs list, and ends up reading this page, and also as the line you have kindly quoted above turned out not to work, I thought it might help that person if somewhere on this page it mentioned that the actual line needed is:

/etc/init.d/asterisk start > /dev/null 2>&1 &

I certainly would not have been able to work this out without your help, and it's been bugging me for weeks, so THANK YOU.