Run a script inside screen using systemd inside LXC container

moi3879

New Member
May 14, 2026
5
0
1
Hello everyone,

I'm pretty new at proxmox and I'm trying to setup a video game server inside an LXC container.

My goal is to build a server that run at startup, auto-save every week, and end when stopping the machine. That's why I looked after systemd.
I use screen because it seems simple to me to attach and detach screens.

So I have a "bootserver" service :
Code:
[Unit]
Description=boot server
After=network.target

[Service]
Type=simple
RemainAfterExit=yes
TimeoutStartSec=90

ExecStart=/usr/bin/screen -DmS mcserver server/bootserv.sh

ExecStop=/usr/bin/screen -p 0 -S mcserver -X stuff "stop\015"
ExecStop=/bin/sleep 20

[Install]
WantedBy=multi-user.target

When y run systemctl start bootserver, the service start and exit but there's no screen session using screen -ls
I've got this status
Code:
● mcserver.service - boot server
     Loaded: loaded (/etc/systemd/system/mcserver.service; enabled; preset: enabled)
     Active: active (exited) since Thu 2026-05-14 10:55:03 CEST; 1s ago
 Invocation: e81a5ba203af4e2db2b3af7512cb9a40
    Process: 331 ExecStart=/usr/bin/screen -DmS mcserver server/bootserv.sh (code=exited, status=0/SUCCESS)
   Main PID: 331 (code=exited, status=0/SUCCESS)
   Mem peak: 1.7M
        CPU: 11ms

mai 14 10:55:03 lxc-deb-mc systemd[1]: Started mcserver.service - boot server.

Note that screen works well when I call it from terminal without using systemd.
Another point is I didn't create any user, so I'm working as root inside the LXC container.

Does someone know how I could run my script inside a screen session launched using systemd services ?
If it's not possible, is there another way to save my lxc server and have a backup on my NAS ?

Thank you all, have a good day/
 
This has little to do with PVE but try to give it the absolute path to the script.
 
Hello,

Thank you for your answer.
Yes it is not necessary about PVE. It's more about LXC container.

With your help I figured out I was working inside /root directory.
I moved everything inside /home, but I still can't run a screen session using systemd.

Is there another way to periodically save my server using PVE tools (I'm thinking about snapshot and Backup ?) ? Is there a way to have a second save sended to a NAS ?

I'll try to ask the screen question somewhere else.
Thank you
 
Moving the file isn't really what I was suggesting. PVE has Snapshot and Backup functionality. Just use that for your guest.
 
Hello,

Yeah, I was a bit fast in my previous answer.
In fact my script's full path was /root/server/bootserv.sh

When I used this full path it didn't worked. That's why I moved everything in another folder : /home/mcserver
After troobleshooting I found a mistake in the script's path (mcserv instead of mcserver) and now it works.

Your answer helped me a lot ! Thank you !