I want to run a service with the output on a certain tty on a Ubuntu server, before any login prompt. I've already successfully made a service that runs htop on tty3:
[Unit] Description=htop on tty3 [Service] Type=simple ExecStart=/usr/bin/htop ExecStop=/bin/kill -HUP ${MAINPID} StandardInput=tty StandardOutput=tty TTYPath=/dev/tty3 Restart=always RestartSec=2 [Install] WantedBy=getty.target And that works mostly fine and as intended, switching to tty3 (alt+f3) brings up htop as expected, and ending the process restarts it instantly. Even stopping and starting/restarting the service from another tty works fine and as intended.
But there is a weird edge case, which is frustrating my efforts for another service somewhat. If I stop the above service, switch to tty3 which gets me a login prompt, switch back to another tty, and start the service again, htop does not come back. I suspect that this is because the normal login/terminal/whatever has now claimed /dev/tty3, so my service is waiting untill it can claim /dev/tty3.
So my question is, how would I clear a specific tty so this service or a service like it can restart, after a regular bash terminal has already claimed it?