user upstart job in ~/.init/ is not found
A few points:
-
User jobs are not enabled by default in Ubuntu. See:
You never need to reboot after creating any type of Upstart job—they are automatically detected by Upstart (using inotify).
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 viaservice
(for convenience). The Upstart equivalent commands arestart
,stop
and,restart
.For user jobs, you must use
start
,stop
and,restart
(or theinitctl
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:
- http://upstart.ubuntu.com/cookbook/#env
- http://upstart.ubuntu.com/cookbook/#export
- http://upstart.ubuntu.com/cookbook/#debugging-a-script-which-appears-to-be-behaving-oddly
Related videos on Youtube
Dave Nolan
Updated on September 18, 2022Comments
-
Dave Nolan over 1 year
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
orinitctl
without usingsudo
. What have I misunderstood?Thanks
-
namuol over 11 yearsHow did you enable User Jobs? The documentation in the answer you accepted is incomplete, at best...
-
-
Sathish almost 12 yearsHow 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?
-
Signa over 11 yearsStrange, 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?
-
ppetraki over 11 yearsYeah I just noticed that, you can't overload existing policies either e.g. user=...,..... Take the second block, copy/paste and change the user= to suit. You can also do groups per the DTD.
-
namuol over 11 years@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. -
ppetraki over 11 years@namoul, I'll patch the actual docs instead. code.launchpad.net/upstart-cookbook
-
Denis Washington over 11 yearsThe referred-to
Upstart.conf
file can be found here. -
glebm about 11 years@denisw Is this a drop-in replacement that just enables user jobs? The Upstart.conf file bundled with ubuntu 12.04 server is a lot bigger
-
geekQ about 11 yearsFollowing Upstart.conf configuration gist.github.com/bradleyayers/1660182 worked for me - Ubuntu 12.04, jobs in ~/.init, no restart after saving Upstart.conf needed.