Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Perhaps I'm misunderstanding with Supervisor does, but perhaps me asking this question will help clear that up. Basically, I have a Supervisor program in my /etc/supervisord.conf file that executes a bash script which simply executes a PHP script. I've been able to successfully get that bash script to run from supervisor only upon launch of supervisor. However, isn't the point of something like supervisor that it runs that tasks in the background at set intervals or something so that I can know it's always running and handling any tasks it might need to according to the script it runs?

Here is the program in my conf file:

[program:program_name_d]
command=/path/to/runme
process_name=%(program_name)s
numprocs=1
autostart=true
share|improve this question

It sounds to me like what your actually looking for is closer to cron. I'm not familiar with supervisor but from the description provided here, it sounds it is trying to be a userspace replacement for certain aspects of init. By this I mean that it focuses in providing:

  • start/stop/restart of services(programs)
  • Automatic program crash detection and restart
  • Controlling the start order of various programs at boot.
  • Delegating management of services to the people who work with them (aka giving web server reboot-rights to the web devs).
share|improve this answer
    
That's right. joshholat is mistaking supervisor as a cron-replacement. Supervisor knows how to do such things but they're intended to support process control (e.g. have a look at the superlance plugin suite). – Theuni Dec 7 '12 at 18:19

What you plan to do is actually possible, but you have to modify your intermediate bash script to actually perform the interval run of your repeating process.

At my company we use python scripts to perform exactly the same tasks of running php scripts in repeated intervals. So what do you have to do in gerneral:

  1. Create a script which is taking the file to be executed and the interval as parameters.
  2. Create a While loop or better, some kind of runnable task which is executed continously and has a shutdown handling in case the task dies unexpectedly. Make the task execute the target program and wait the interval. Keep in mind to wait until your target has finished execution before waiting.
  3. In Supervisor, set the intermediate script as target and provide the params. If you created a goog implementation, you should be able to use the script for multiple scripts that can be executed in the same way.
  4. Update your supervisor conf and start the process.

Tada: You have a cronjob-like process, which is run and monitored by supervisor.

Of course you can also extend your script to be able to handle dates, or weekdays, or time spans on a specific time span. So that your script for example is only executed on a sunday morning at 1 am or so.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.