Please note this is a FreeBSD question and not a Linux question. Please don't answer with how it would be done on Linux or systemd or any of that.

I have a situation where memcached is crashing. It's not that repeatable and I'll eventually figure it out. In the meantime, I need to ensure that memcached is running. If it's not, I need to restart it. It is installed via pkg and starts via /usr/local/etc/rc.d/memcached. There are a few choices.

  1. I could write a watchdog script and invoke it every like 10 minutes or something via cron. Kinda ugly, but would work. Main thing here is that I need to go write that script. Calling service memcached status, evaluate the result, maybe call service memcached start. I know how to write that, but it seems clunky. I'd rather just use a mechanism that already exists.
  2. I could write a do ... until loop script. Then I could modify /usr/local/etc/rc.d/memcached. But I want to keep files that were installed by the package pristine. I don't want to perpetuate my changes each time I upgrade the package.
  3. I drop a script into /usr/local/etc/periodic.d/hourly and have it invoked by periodic(8).

Is there some easy, FreeBSD-native mechanism that I'm not thinking of to keep processes running? Or am I just overthinking it and I should just go write my 8 line script and start calling it from cron?

2 Answers 2


What you're looking for is called a supervisor. I don't think FreeBSD comes with one out of the box. But there are some in the ports. I see at least;

  • supervisord is available as a port called py-supervisor (the port has several flavors, install with pkg install py37-supervisor or whatever matches your Python version).
  • daemontools is available as a port.
  • Monit is available as a port.
  • FSCD is available as a port called fsc.

I suggest supervisord. Install the package and add a stanza to /usr/local/etc/supervisord.conf:


To run supervisord at boot time, edit /etc/rc.conf or /etc/rc.conf.local to have the line


Whichever supervisor you choose, make sure to disable the direct starting of memcached.

  • I'm confused. You've linked to a man page. So this obviously exists. I'm running 12.1-RELEASE-p8. But man supervise and man 8 supervise both come up empty on my system. Likewise pkg search supervise comes up empty. What am I doing wrong?
    – Paco Hope
    Commented Aug 29, 2020 at 1:18
  • 1
    @PacoHope My bad, I'd read that man page too quickly and hadn't realized this wasn't a new basic FreeBSD program, but the old daemontools utility, which is part of a port. (I don't understand why the FreeBSD web interface shows a seemingly random set of ports.) I would generally not recommend daemontools because it's its own world (a bit like systemd…) so I've changed my recommendation to supervisord and also added a couple more alternatives (not an exhaustive list). Commented Aug 29, 2020 at 8:51

You could do the restart with daemon(1) using the -r flag. Much simpler, IMHO. BTW, I maintain the memcached port, so I may be able to help with the memcached crashing issue, let me know details if you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .