Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I've currently got 2 ttys logging in automatically, but I need to launch a node script from one and a C program from another as soon as the device loads.

The device is a Raspberry Pi running Raspbian. It's set up to function like an appliance, these two programs will run for a few hours at a time before the device is turned off.

I've successfully launched my programs via /etc/rc.local but it seems that this isn't the same as actually launching from tty, they are closed before the prompt loads.

share|improve this question
Have you tried openvt myprogram? It should create a tty and run your command there. – donothingsuccessfully Dec 13 '12 at 21:10
Nope, checking it out now, thanks! – thewebguy Dec 13 '12 at 21:27
@donothingsuccessfully Thanks, this is what I needed! – thewebguy Dec 19 '12 at 15:06
up vote 3 down vote accepted

I think it's possible to start whatever you want from /etc/inittab

e.g. (/etc/inittab excerpt)

c1:12345:respawn:/sbin/agetty 38400 tty1 linux

# Launch top redirecting its output to tty2, without redirecting input
c2:2345:respawn:/usr/bin/top >/dev/tty2 2>&1

# Launch ascii-invaders with redirected input 
# (you will be able to control the game with keyboard after switching to tty3)
c3:2345:respawn:/usr/games/bin/ascii-invaders </dev/tty3 >/dev/tty3 2>&1
share|improve this answer

Depending on what you really need, launching form init script might indeed be better. You'd probably have to daemonize it somehow (e.g. by running it on background) though, otherwise the init system will wait until the programs finish. On the other hand, if you need to interact with the programs, running them with a controlling terminal is easier. You can combine both approaches by running it in tmux or screen from an init script.

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.