Score:0

Starting screen session as a service, how do I transmit the screen session output (back) to the service log?

us flag

I have an application that is a interactive shell. I want this application to run as a service. To be able to access the shell while the service is running, I figured its best to start the service as a screen session that launches the application.

But this creates a problem. The service log doesn't actually show any of the output that I can see in the screen session.

How can I transmit the screen session output to the service log?

[Unit]
Description=CSGO Server
After=network.target

[Service]
Type=forking
WorkingDirectory=/home/birger/csgo-server
ExecStartPre=-/usr/bin/screen -S ${SCREEN_TITLE} -X kill
ExecStart=/usr/bin/screen -dmS ${SCREEN_TITLE} -O -l /usr/bin/bash\
 -c /home/birger/csgo-server/update-and-start
ExecStop=/usr/bin/screen -S ${SCREEN_TITLE} -p 0 -X stuff "exit^M"
Environment=SCREEN_TITLE=csgo
RemainAfterExit=false
Restart=always
RestartSec=5s
SuccessExitStatus=1

[Install]
WantedBy=default.target

Started by

systemctl --user start csgo.service

Viewing logs by

journalctl -u csgo.service

Output (is blank):

-- Logs begin at Sat 2020-02-22 14:17:45 CET, end at Mon 2021-08-16 15:06:35 CEST. --
-- No entries --

But if I attach to the screen I can see that there is actually loads of text, just not displayed in the service log.

anx avatar
fr flag
anx
Why are you even doing this? srcds has the `rcon` and `steamcmd_script` features specifically so you do *not* have to pull unreliable tricks like running it in a screen session. Just run the srcds executable directly in ExecStart and enjoy having its output properly forwarded to journal!
birgersp avatar
us flag
You got a point. And I guess generally speaking, there is no way to "transmit" the output from screen to the journal?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.