I am running Ubuntu server 11.04. I have created an Upstart user job as described here.

I have the following file at my /home/myuser/.init/sensors.conf:

start on started mysql
stop on stopping mysql

chdir /home/myuser/mydir/project
exec /home/myuser/mydir/env/bin/python /home/myuser/mydir/project/manage.py sensors


respawn limit 10 90

As myuser I can start, stop, and reload the job fine- it works perfectly:

$ start sensors
sensors start/running, process 1332
$ stop sensors
sensors stop/waiting

The problem is that the job is not starting automatically at boot when mysql starts. After a fresh boot, mysql is running but my sensors job is not.

What's strange, is that although the job doesn't begin on bootup, if I use sudo to restart mysql it does indeed start my job. The following commands are run as myuser from a fresh startup:

$ status sensors
sensors stop/waiting
$ sudo restart mysql
mysql start/running, process 1209
$ status sensors
sensors start/running, process 1229

The documentation for Upstart user jobs is pretty limited. What is the correct technique to have a user job start automatically on startup of the system?

I know I can just throw something in rc.local to start it, or I could move my sensors.conf to /etc/init but I'm curious if there is a way to do it using just Upstart.

2 Answers 2


The problem is that user jobs aren't loaded into Upstart until the user creates an Upstart session by running one of the initctl commands.

I've described it in more detail at http://bradleyayers.blogspot.com.au/2012/04/enabling-upstart-user-jobs-to-start-at.html and also written an Upstart job that works around the problem.

  • There's another way to do this documented at upstart.ubuntu.com/cookbook/… — it has a bug though, you'll need to change "start session_init" to "start session-init".
    – natevw
    Oct 8, 2014 at 23:47

Looking at sources like /etc/init/mysql.conf and http://upstart.ubuntu.com/cookbook/#start-on it seems to me you should change your start on line to something like this:

start on (mysql and runlevel [2345])

I'm not sure I agree that upstart lacks documentation, but I sure do have a tough time understanding the docs sometimes. I usually just do trial and error until its working. The solution above may be overkill actually... something as simple as this may be sufficient:

start on mysql
  • It's not that upstart lacks documentation in general, it's that it doesn't have much documentation regarding user jobs- jobs placed in /home/$USER/.init (not jobs placed in /etc/init).
    – dgel
    Nov 24, 2011 at 0:10
  • I tried your suggestions but no difference. It's not a problem with my start on line, but it's just the fact that upstart only loads /etc/init on startup, but not user init files in their $HOME/.init
    – dgel
    Nov 24, 2011 at 0:12
  • Sorry, missed that this was a user job and not a job in /etc/init. You are correct that documentation appears to be lacking for that and I'm not sure how to ensure ~/.init scripts are started. Nov 24, 2011 at 0:44
  • The docs I could find indicate the $HOME/.init jobs are not enabled by default and some changes to /etc/dbus-1/system.d/Upstart.conf might be required. upstart.ubuntu.com/cookbook/#run-a-job-as-a-different-user Nov 24, 2011 at 1:07

You must log in to answer this question.

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