1

I have added a crontab entry via crontab -e for the current user:

@reboot supervisord -c /etc/supervisord.conf

Yet after the reboot, supervisord demon is not running. I need to run the command again in bash. Only a second try yields in an error I expected right away after setting up the cronjob.

$ supervisord -c /etc/supervisord.conf
$ supervisord -c /etc/supervisord.conf
Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.

Why doesn't my cronjob work and how do I start supervisor daemon on boot?

  • Have you tried using the full path to the supervisord binary? (The path your cron task has may be different to that you set in your shell environment). – Drav Sloan Jul 22 '14 at 13:43
  • @DravSloan Yes, this has resolved my issue. Can you please add your comment as an answer for me to upvote and accept? And bonus, if you could elaborate as to why the path misbehaves and is required for my setup to work. – k0pernikus Jul 22 '14 at 15:27
2

cron by default running in a minimal environment, from man 5 cron:

Several environment variables are set up automatically by  the  cron(8)
daemon.  SHELL is set to /bin/sh, and LOGNAME and HOME are set from the
/etc/passwd  line  of   the   crontab's   owner.   PATH   is   set   to
"/usr/bin:/bin".   HOME,  SHELL, and PATH may be overridden by settings
in the crontab;

Your supervisord executable may not be in /usr/bin or /bin, so cron can not find it and fail to run.

A good practice, safest way is always use full path to your executable in cron entry, if you're not sure it's in default path of cron.

Or you can change PATH globally for cron by edditing /etc/crontab:

$ cat /etc/crontab 
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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