Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Running 12.04, I have the following upstart job in ~/.init/:

# myjob

start on net-device-up
stop on [!12345]

script

echo ">> hello from user script" >> ~/tmp/upstart.log

end script

After rebooting my machine

service myjob start
# => myjob: unrecognised service

initctl does list the job, but running it without sudo throws an error:

initctl start myjob
# => initctl: Rejected send message, 1 matched rules; type="method_call", sender=":1.100" (uid=1000 pid=13349 comm="initctl start thunderbird ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")

I would expect to be able to start the job using service or initctl without using sudo. What have I misunderstood?

Thanks

share|improve this question
1  
How did you enable User Jobs? The documentation in the answer you accepted is incomplete, at best... –  namuol Dec 22 '12 at 10:03
add comment

1 Answer 1

up vote 9 down vote accepted

A few points:

  1. User jobs are not enabled by default in Ubuntu. See:

  2. You never need to reboot after creating any type of Upstart job—they are automatically detected by Upstart (using inotify).

  3. The service command is not part of Upstart—it is the SystemV tool to manipulate SysV jobs. However, Upstart provides SystemV compatibility such that Upstart system jobs can also be manipulated via service (for convenience). The Upstart equivalent commands are start, stop and, restart.

  4. For user jobs, you must use start, stop and, restart (or the initctl equivalents).

Finally, note that user jobs are very basic currently. We plan to enhance them significantly for 12.10 but for now be aware that:

  • Upstart will run all user jobs using /bin/sh -e regardless of which shell you use by default. That -e is also very important (man sh for details).
  • Upstart will only set a minimal set of variables in the user job environment. Hence, you should probably set variables like HOME like this:

    env HOME=/home/james

See:

share|improve this answer
    
Thanks James, I thought I'd read that user jobs were enabled in Precise. Thanks for clearing up my confusion. –  Dave Nolan Jun 20 '12 at 8:37
    
How would I auto-start a user job on Ubuntu 12.04? I've found a tutorial, which worked for me on Ubuntu 11.10, but not on Ubuntu 12.04. Any ideas? –  bouke Jul 1 '12 at 11:00
4  
Strange, the documentation doesn't seem to mention how to enable user jobs, it only mentions the config file, and that the administrator must do it. Aren't we all administrators? –  Ropez Oct 22 '12 at 10:26
2  
@ppetraki could you please post an answer clearly outlining the changes to be made to /etc/dbus-1/system.d/Upstart.conf? It's baffling how vague and incomplete the documentation on such a critical system utility is. –  namuol Dec 22 '12 at 10:01
1  
The referred-to Upstart.conf file can be found here. –  denisw Jan 9 '13 at 8:54
show 4 more comments

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.