I have an application that writes and reads to an interactive terminal, and when I run it via the shell, it works as expected. However, when I run it as a systemd service, it seems as though the application isn't capturing the stdout or stderr.

I have tried modifying the StandardOutput and StandardError in the service definition to journal+console and tty.

The service section of my systemd file looks like this :

ExecStart=/bin/bash -c "cd /somedir && python3 myapp.py" 

I have also tried setting TTYPath=/dev/tty2, but no luck.

I am running Ubuntu 16.04.

Edit: More info

When I run this app, the interactive session that it creates does not get read from/written to in the terminal where I actually run the app. It emulates its own terminal.

See link here:


and here:


  • 1
    What does systemctl status -l (servicename) show? – ErikF Feb 11 '18 at 6:18
  • @ErikF it shows that it's running, are you looking for something specific? – aleksk Feb 11 '18 at 7:54
  • I wanted to know whether or not the service had died, so that's helpful. You indicated that the program reads input: does this program require input to start working? If so, are you supplying that input from somewhere? – ErikF Feb 11 '18 at 8:09
  • Maybe you want to first test the tty output with something like ExecStart=/bin/echo "Hello" to exclude problems with the myapp.py application. Just tested on a Ubuntu 16.04 VM and TTYPath=tty2. Saw that the getty@tty2 service is only activated when you switch to it. So defined a dependency Requires=getty@tty2.service, now it seems to work but the first output of executing the service is not logged. – Thomas Feb 11 '18 at 8:59
  • if you want to run a different service on tty2, I think you would want to mask getty@tty2 (or maybe autovt@tty2, which is how it is triggered on VT switch). Typically getty services will be triggered on tty1 through tty6. See docs for logind.conf – sourcejedi Feb 11 '18 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.