Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would I go about replacing a TTY with a custom script in CentOS 6. CentOS 6 uses upstart instead of the standard SysV init scripts, so I'm having difficulty figuring out how it all works.

Typically (in SysV init scripts), I would edit /etc/inittab and replace one of the mingetty lines with my script, like this:

1:2345:respawn:/root/myscript tty1

However, with Upstart, this file doesn't the relevant lines, so I'm unsure of how to accomplish this.

share|improve this question
Have you looked at the documentation? The RedHat documentation has a section on service initialization, and there is of course a website for Upstart as well. – larsks Oct 20 '11 at 14:27
I did, the documentation wasn't very helpful about replacing an existing tty with something else. – devicenull Oct 20 '11 at 14:46
It looks like you've figured it out anyway. Congrats! – larsks Oct 20 '11 at 16:10
up vote 5 down vote accepted

I've figured it out.

First I modified /etc/init/start-ttys.conf to have this for the script section:

    . /etc/sysconfig/init
    for tty in $(echo $ACTIVE_CONSOLES) ; do
          [ "$RUNLEVEL" = "5" -a "$tty" = "$X_TTY" ] && continue
            if [ "$tty" == "/dev/tty1" ]; then
                    initctl start myjob TTY=$tty
            initctl start tty TTY=$tty
end script

I then created /etc/init/myjob.conf:

stop on runlevel [012456]

exec /usr/bin/openvt -c 1 -f -e /root/myscript

This ultimately starts /root/myscript on tty1, instead of mingetty. I'm unsure if this the is simplest way of doing it, but it works quite nicely.

share|improve this answer

Your Answer


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.