S
S
Sergey Torop2022-03-30 23:22:48
linux
Sergey Torop, 2022-03-30 23:22:48

How to output data from script to tty1 text console after linux boot?

1. There is a python script that I want to run through systemd and get output when Linux starts on an active text console, usually / dev / tty1 (via Alt-F1).

For example,

[Unit]
Description=My Service
After=basic.target
[Service]
Type=simple
User=root
Environment=TERM=linux HOME=/opt/mydir
ExecStart=/usr/bin/env python /opt/mydir/starter.py

When the server starts, the script is launched, but no data is output to the text (Alt-F1) console. How to reach a conclusion?
Do I need to modify the script or can this be done using Linux tools?

2. The second question is running tmux (with 4 screens at the same time) when the overall screen is divided into 4 parts, preferably also through systemd, since I don’t see another generally accepted option (/etc/rc.local is abolished).
Is it possible to register this launch also with the ExecStart parameter in the systemd unit?

In other words, I want to see output to the text console (Alt-F1) from scripts after starting Linux (in particular, Ubuntu server 20.04).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2022-03-30
@TSerge

A quick googling suggests

StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty1

The only thing is that the console will be completely occupied from the word, it will no longer be possible to use this console for another.
As for tmux, it might be more practical to call it as a separate unit, and write the After dependency in the current unit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question