Super User is a question and answer site for computer enthusiasts and power users. 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'm trying to autostart an interactive C++ program at boot before TTY1 appears.

I have created a file called /etc/systemd/system/myapp.service with the following contents:

[Unit]
Description=myapp

[Service]
Type=oneshot
ExecStart=/home/xxx/myapp.exe start
StandardOutput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

And then ran

sudo systemctl enable myapp

Unfortunately, it doesn't work as expected. I can't interact with myapp, and I do not want TTY1 to appear until the program ends


UPDATE: My app now works before the TTY appears. /etc/systemd/system/myapp.service now contains:

[Unit]
Description=myapp
After=sysinit.target

[Service]
Type=oneshot
StandardOutput=tty
RemainAfterExit=yes
ExecStart=/home/xxx/myapp.exe start

[Install]
WantedBy=multi-user.target

But I still can't interact with my program.

share|improve this question

I was able to interact with my program by adding a TTY StandardInput line to the systemd service, and disabling the TTY1 systemd service.

Here are the final contents of /etc/systemd/system/myapp.service:

[Unit]
Description=myapp
After=sysinit.target

[Service]
Type=oneshot
StandardInput=tty
StandardOutput=tty
RemainAfterExit=yes
ExecStart=/home/xxx/myapp.exe start

[Install]
WantedBy=multi-user.target

And here is the command to disable the TTY1 systemd service:

sudo systemctl disable getty@tty1.service

Now, the program appears interactively on TTY1.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .