You are not logged in.

#1 2011-11-02 05:04:06

CaseMonster
Member
Registered: 2011-06-17
Posts: 10

[Solved] systemd - Auto starting programs under specific tty

Is there any way to start a program on an empty tty?

Currently i run htop on tty11 and a log on tty12 using the default startup scripts with something like this,
htop:2345:respawn:/usr/bin/htop -d=10 > /dev/tty11

I've tried played around with systemd for a while but can't get it working. There doesn't seem to any documentation for launching anything except additional gettys, so i tried to modify one of the .service file for htop but didn't make any progress.

Does anyone else know how to get this working?
Thanks

Last edited by CaseMonster (2011-11-02 23:34:20)

Offline

#2 2011-11-02 07:21:20

CaseMonster
Member
Registered: 2011-06-17
Posts: 10

Re: [Solved] systemd - Auto starting programs under specific tty

Okay, here's what i have so far.


[Unit]
Description=htop on tty11
BindTo=dev-tty11.device
Requires=dev-tty11.device
After=dev-tty11.device systemd-user-sessions.service

[Service]
Environment=TERM=linux
ExecStart=/usr/bin/htop -d=10 > /dev/tty11 < /dev/tty11


On the boot log it says "Starting htop on dev/tty11", "Started htop on /dev/tty11" but display is blank on tty11 and after logging on there isn't any process named htop running.
I'm not positive where custom services files are supposed to go in the /etc/systemd/ dir, but the only time i get feedback that it started is when i put it in /getty.target.wants/

Last edited by CaseMonster (2011-11-02 07:22:47)

Offline

#3 2011-11-02 08:00:36

CaseMonster
Member
Registered: 2011-06-17
Posts: 10

Re: [Solved] systemd - Auto starting programs under specific tty

Okay I figured out how to properly run services on systemd, here's the newest .service file

[Unit]
Description=htop on tty11
After=dev-tty11.device systemd-user-sessions.service

[Service]
ExecStart=/usr/bin/htop -d=100 > /dev/tty11 < /dev/tty11
Type=oneshot

[Install]
WantedBy=multi-user.target


And when running i get this

systemctl status htop.service
htop.service - htop on tty11
      Loaded: loaded (/lib/systemd/system/htop.service; enabled)
      Active: failed since Wed, 02 Nov 2011 02:57:08 -0500; 1s ago
     Process: 1452 ExecStart=/usr/bin/htop -d=100 > /dev/tty11 < /dev/tty11 (code=exited, status=1/FAILURE)
      CGroup: name=systemd:/system/htop.service

Offline

#4 2011-11-02 10:05:35

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: [Solved] systemd - Auto starting programs under specific tty

You can't perform redirection like that. > and < are shell-specific (bourne-ish, I guess) keywords that imply that the standard file descriptors should be cloned. Systemd doesn't know about this and will pass those arguments literally.

I have no idea if this will work, but you can try the following:

Type=simple
ExecStart=/usr/bin/htop -d=100
StandardInput=/dev/tty11
StandardOutput=/dev/tty11

Offline

#5 2011-11-02 22:01:45

CaseMonster
Member
Registered: 2011-06-17
Posts: 10

Re: [Solved] systemd - Auto starting programs under specific tty

Bingo got it. https://fedoraproject.org/wiki/User:Joh … stemd.exec


[Unit]
Description=htop on tty11

[Service]
Type=simple
ExecStart=/usr/bin/htop
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty11

Offline

#6 2017-12-24 15:14:01

poleprogger
Member
Registered: 2016-02-06
Posts: 2

Re: [Solved] systemd - Auto starting programs under specific tty

Thanks for this solution!

I modified it a little due to a systemd warning message
[Unit]
Description=htop on tty7

[Service]
Type=simple
ExecStart=/usr/bin/htop
StandardInput=tty
StandardOutput=tty
TTYPath=/dev/tty7

[Install]
WantedBy=multi-user.target

Last edited by poleprogger (2017-12-24 15:32:07)

Offline

#7 2017-12-24 15:37:51

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 12,426
Website

Re: [Solved] systemd - Auto starting programs under specific tty

Please do not necrobump, poleprogger.

https://wiki.archlinux.org/index.php/Co … bumping.22

Closing.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

Board footer

Powered by FluxBB