upstart job works only with manual start/stop

11,956

As of my experience you don't have to "enable" anything, just put the .conf in /etc/init and enjoy.

You can verify that the script does run by adding a line like this in the script:

echo "alive" > /alive_and_well

This will create file "alive_and_well" in your root dir if the script runs.

If it doesn't, the problem is most likely in the "start on" stanza. Here's what I use for such things (known to work):

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]

Also shebangs in Upstart scripts are not supported, so "#!/bin/bash" is useless (AFAIK).

Share:
11,956

Related videos on Youtube

Alexander
Author by

Alexander

Updated on September 18, 2022

Comments

  • Alexander
    Alexander over 1 year

    I have a very small upstart job in /etc/init/tsm.conf to start backup client after network starts. It works just ok if I start/stop it manually via service tsm start|stop|status. But service tsm enable says tsm: unrecognized service. So it doesn't start on boot automatically. sudo service --status-all also doesn't show it in the list of known jobs.

    Here it is:

    start on started networking
    stop on stopped networking
    
    respawn
    
    script
    #!/bin/bash
    dsmc schedule > /dev/null
    end script
    

    I run ubuntu 12.04.4. Upstart version is 1.5-0ubuntu7.2. Could anybody help me? :)

    UPDATE

    Using initctl list and other initctl commands shows my job.

    • c0rp
      c0rp over 10 years
      Did you put start-stop script int /etc/init.d?
    • Alexander
      Alexander over 10 years
      It seems like /etc/init.d is used by other "old-style" init system. Or?...
    • c0rp
      c0rp over 10 years
      Hmm, may be. I will read about it. I'm still using init.d daemons. If I find some interesting information I will write you
  • Shnatsel
    Shnatsel over 10 years
    /etc/init.d/ is for sysvinit compatibility, the actual jobs reside in /etc/init/
  • Anish
    Anish over 10 years
    Indeed; and the service command that the question used requires this sysvinit compatibility to be in place for the job he created. If you care to look, you'll find that all other system-provided upstart jobs have one.