Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

Preface: I have a server running on an old laptop. The screen is always on with a login prompt, but because its keyboard is in pretty bad shape, I use it exclusively via ssh. The screen is in a good position, though; I want to use it to display a clock and some stats about what my server is doing. I have scripts to display all those things, but I want to always show them on the monitor screen.

My question is, how do I get my script (called HUD) to run on /dev/tty1, instead of the login prompt. Hopefully, it should be possible to accept keyboard input as well as display its output, so that it can use the keyboard to show more info where needed in a future version. I'd also like tty2 etc. to remain active as login screens, in face I actually do need to login locally.

For a start, I tried creating a script that I can run from ssh to start the HUD. It goes something like this:

    flock -n 9
    watch --interval 0.2 --precise --color --notitle --exec /path/to/script & disown
) 9> /var/lock/hud > /dev/tty1 2> /dev/tty1 < /dev/tty1

(I had to use & disown instead of nohup because nohup recognized the tty and redirects output to nohup.out instead.)

This sort-of works. However, it has a few issues:

  • It doesn't steal the terminal's keyboard input, so you can't ctrl+c to get out of it (nor change the script to actually use the keyboard input), and if you press enter it show it and scrolls the display, never refreshing it correctly afterwards.
  • Oddly, if I disconnect the ssh session which created it, it stops working and shows a message: exec: No such file or directory. If I reconnect to ssh, it resumes functioning properly.
  • It feels hackish.

Is there a better way to do this? How?

share|improve this question
up vote 0 down vote accepted

I found that indeed there's a simple way. You can quite easily use an init script to create a service that runs on the console. Here's an example.

$ cat /etc/init/hud.conf

console owner

pre-start script
    setterm -powerdown 0 -blank 0
end script

exec /home/configurator/bin/hud-display

post-stop script
    setterm -blank 2
end script

The pre-start and post-stop is only used so that the screen doesn't turn off while this service is running, and will be cleared and reset to my defaults when the service is finished.

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.