Starting screen in detached mode - Autostart

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
Demophobie
Level 1
Level 1
Posts: 6
Joined: Wed Feb 03, 2021 4:30 am

Starting screen in detached mode - Autostart

Post by Demophobie »

Hi!

I tried to autostart a screen session with systemd on Linux Mint 21.1:

Code: Select all

[Unit]
Description=powercontrol service

[Service]
Type=simple
ExecStart=/bin/sh /etc/powercontrol.local
Restart=always
RestartSec=30
User=pathaa

[Install]
WantedBy=network-online.target
The script powercontrol.local looks like this:

Code: Select all

#!/bin/sh
sleep 10
cd /home/pathaa/powercontrol
screen -d -m -c screenconfig
I enabled it and it starts well. But "screen -list" shows after restart:

Code: Select all

There is a screen on:
    1448..NUC8i3BEK-Server  (23.03.2023 12:10:13)   (Dead ???)
Remove dead screens with 'screen -wipe'.
1 Socket in /run/screen/S-pathaa.
I cant resume the session: "There is no screen to be resumed." But starting powercontrol.local manually works like a charm.

I dont know what to do to heal it.
Last edited by LockBot on Sat Sep 23, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Demophobie
Level 1
Level 1
Posts: 6
Joined: Wed Feb 03, 2021 4:30 am

Re: Starting screen in detached mode - Autostart

Post by Demophobie »

I found the solution:

Type=forking in the powercontrol.service in systemd/system healed ist.
Locked

Return to “Scripts & Bash”