The Upstart Cookbook recommends a post-stop delay (http://upstart.ubuntu.com/cookbook/#delay-respawn-of-a-job). Use the respawn stanza without arguments and it will continue trying forever:
post-stop exec sleep 5
(I got this from this Ask Ubuntu question)
To add the exponential delay part, I'd try working with an environment variable in the post-...
You are likely comparing systemd docs you've read online for a different version instead using the docs on your system that match your version.
Check man systemd.unit on your own system. You may find that on your version, the directive is named
StartLimitInterval= and should be used [Service], not [Unit].
I found the answer by searching for systemd ...
So for some reason initctl likes it and service doesnt...
sudo initctl start test
test start/running, process 8776
A bug in EC2 Linux me thinks. My example exactly conforms to the documentation but no biggy to switch to using initctl
If you like to check which services are running you also can do this:
sudo initctl list
And to verify where the log error ...
I did not get the mkfifo trick to work satisfactorily; it did not seem to capture stderr, and attempts to redirect caused Upstart to bail with no errors.
It also has an unfortunate side effect of making the logger process hang around as a child of init, so the information about who "owns" the logger is lost, and anyone not already aware of the mkfifo might ...
When autossh invoked by sudo or init process, autossh use identity/ssh-keys file provided by root user (e.g. /root/.ssh/sshkeys). When you try run autossh from terminal, maybe you use non-root user. Thus, autossh use identity/ssh-keys file provided by that user (e.g /home/non-root/.ssh/sshkeys).
To get expected behavior, you can provided identity file in ...
I came across this similar situation and it was because the port was already used by another service.
How I found it out ?
rather than starting it as a service and it should display the error message.
I have manually stopped all my important services like LDAP, PostgreSQL and MySQL. And I did run:
The -f force parameter to ignore the init system. After the reboot I was able to make a simple reboot without force mode.
Another solution could be more agressive but useful to know, send a magic sysreq remotely with:
echo b > /proc/sysrq-...
If an init.d script doesn't terminate, the normal system start-up will be interrupted indefinitely.
One common solution is to incorporate a counter in the while loop and exit with an error message after a given number of while loops. If you're waiting for an external command that doesn't have a timeout option, have a look at this question.
As already mentioned, use respawn to trigger the respawn.
However, the Upstart Cookbook coverage on respawn-limit says that you'll need to specify respawn limit unlimited to have continual retry behaviour.
By default it will retry as long as the process doesn't respawn more than 10 times in 5 seconds.
I would therefore suggest:
respawn limit ...
Using chdir inside the script clause is plain wrong, and it means that you fail to understand a very basic idea in upstart (no offence meant). (As a side note, the exec keyword is just useless, but does no harm).
There is an idea very central to understanding how upstart works. Upstart tries to determine which process of the processes that were spawned by ...
I would say don't look at the current distro to determine which init system to use to manage daemons:
It's a little nebulous to determine a distro (as described in Dennis's answer)
the init system in use changes between versions of a distro (as Michael Hampton noted, the big name distros are all gravitating toward systemd; Ubuntu is currently the one big-...
According to the upstart cookbook/intro linked here, upstart will emit a 'filesystem' event when all mounts are completed. You should be able to "start on filesystem" the required service to achieve what you're looking for, unless you're only wanting certain (but not all) filesystems to be mounted prior to service invocation?
This is because, on Ubuntu 15.04, /sbin/init is NOT Upstart.
Upstart is at /sbin/upstart.
By default, 15.04 is using Systemd instead of *Upstart *.
You should look into creating a Systemd unit file instead.
I have done an improvement to Roger answer. Typically you want to backoff when there is a problem in the underlying software causing it to crash a lot in a short period of time but once the system has recovered you want to reset the backoff time. In Roger's version the service will sleep for 60 seconds always, even for single and isolated crashes after 7 ...
I tend to use eval $(cat /etc/environment | sed 's/^/export /')
It takes each line in /etc/environment, prepends export, and evaluates it:
exec /bin/bash <<'EOT'
eval $(cat /etc/environment | sed 's/^/export /')
This question seems to contain a lot of sub-questions about how to handle environment variables in an Upstart script, so I thought I would share a few things I do to handle and test my environment for Upstart and Cron.
The first thing to know about Upstart, and the like, is it does not share the same environment as your active terminal, so something like:
Building on the accepted answer (and since I do not have enough rep to comment on it)
Respawn is NOT a mongo configuration parameter, it is for the upstart service configuration file.
respawn limit 10 90
Digital Ocean has a nice tutorial for using upstart and systemd (newer).
When /var/log/upstart/api-access.log is archived the original filesystem link to it is removed, however the inode remains as it's being held by the exec-ed process. The process continues to write to this inode even while there is no reference to it and will continue to do so until the process is restarted.
Unless there a particular reason you are ...
One way to solve this is to change the order that these things load by modifying the order the init script calls them. There may be other (easier) ways to do this, but the bare metal way would be to -
Find the runlevel the server is running on by issuing the command (as root) "runlevel".
Go to /etc/rcX.d where X is the runlevel number you are in.
You will ...
Looks like everything works like upstart is supposed to (I had put my files in the wrong directory!):
I just did the following:
echo "manual" > /etc/init/atd.override
and voila -- the atd process no longer starts up on reboot!
You can enable debugging to the system log with the initctl log-priority <priority> command.
To change the priority with which Upstart logs messages to the system
log, you can change the log priority at any time using log-priority
command as follows:
initctl log-priority <priority>
Where <priority> may be one of:
sudo persists as long as the process is running, so the solution is to use the setuid and setgid stanzas of upstart. The problem with that is that the line that sends the PID of the daemon needs root privileges. Here is a workaround:
start on runlevel 
stop on runlevel 
sudo is not the right tool for anything regarding init systems. please avoid using it if possible.
setuid and setgid affect all stanzas of the upstart job, including the pre-start.
This can easily be worked around with the following job, my-service-prep.conf:
start on starting my-service
exec install -o my-user -g my-group ...
If you press F5 in htop you see the process hierarchy, which helps explain what you're seeing here.
They're probably ordered like this 586 -> 677 -> 1077 -> 1082.
586 'su' - spawns
677 'export ...; cd ...; thin start ...' which spawns
1077 'thin start ...' which spawns
On RHEL 6 to respawn a script, go to /etc/init and create a file
And add this content
start on stopped rc RUNLEVEL=
stop on runlevel [!12345]
exec /you/respawned/script.sh -your -parameters
Save file and then launch this command (without .conf of file)
My understanding of the Vagrant boot sequence is that Vagrant mounts /vagrant (and any other shared filesystems you have defined) using SSH, after the boot sequence has completed.
As such, you'll probably want to run systemctl start my.service in a provisioner, with run: always specified, so the provisioner runs on every boot, not just when the VM is ...