Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The new CentOS 6 comes with Upstart, replacing init. I am trying to convert an /etc/inittab file to the new upstart format. This particular server only has 15 or so inittab entries, however, other servers have >30. We are mainly wanting the 'respawn' part of inittab and upstart. However, I have been reading all the upstart documentation I can find, (which is pretty much ALL based on Ubuntu, and apparently on an older version of upstart) and not getting anywhere. I can create a config file (lets call it /etc/init/test.conf). The file contains this (note, anonymized)

start on runlevel [345]
stop on starting shutdown

respawn
#Comment about what it does
exec su -c "/usr/bin/ssh -2CNL 11111:127.0.0.1:11111 10.10.1.1" username

If I issue a initctl reload-configuration the job is recognized. I can start it by calling initctl start test and the job will start.

However, this won't work on a reboot, only manually. I have tried modifying the start command to the following, all with no luck

start on started

start on (local-filesystems and net-device-up IFACE!=lo)

start on net-device-up IFACE=eth0 

and about a dozen other ways I could see mentioned in different examples. none seem to start the script. (test.conf, like all the other files in this folder, are owned by root, and 644)

Am I missing something glaringly obvious?

share|improve this question

3 Answers 3

up vote 24 down vote accepted

I found a very, very, very helpful upstart script for people that are having problems in the future. Put this into /etc/init/

# /etc/init/debug.conf
start on ( starting JOB!=debug \
or started JOB!=debug \
or stopping JOB!=debug \
or stopped JOB!=debug )
script
exec 1>>/tmp/log.file
echo -n "$UPSTART_JOB/$UPSTART_INSTANCE ($0):$$:`date`:"
echo "Job $JOB/$INSTANCE $UPSTART_EVENTS. Environment was:"
env
echo
end script

This script basically logs all jobs that start or stop. I have found that CentOS 6 does not 'emit' anything about runlevels. (nor some of the other common events I had tried.'). Looking the log file that debug job creates in /tmp/log.file was very helpful. By changing the start of my script from:

start on runlevel [345]

to

start on started sshd

all my jobs appear to start up correctly. This was a pain in the rear, since every example I found used the former syntax..

share|improve this answer
    
If I could vote that up more than once, I would have. –  Peter Mounce Mar 27 '12 at 15:36

Sorry for necroposting, but I managed to solve this problem by using the following:

start on stopped rc RUNLEVEL=[345]

"stopped" is not a typo -- rc seems to stop upon entering a runlevel.

share|improve this answer
1  
Thanks for the tip! Necroposting is great, when its helpful! –  Brian Mar 19 '12 at 14:33

This is what I did (CentOS 6, Upstart 0.6.5) to debug respawn issues. In a different terminal, do

sudo initctl log-priority debug 
sudo tail -F /var/log/messages
share|improve this answer

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.