Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

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.