You are not logged in.

#1 2022-10-14 07:58:52

Iulian
Member
Registered: 2019-08-01
Posts: 27

Can you give input to systemd services ?

Basically i have a minecraft server that i run as a systemd service but i don't want to actually log into the game everytime i might want to change something with a command is it possible?

This is the current service file i have at the moment

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

[Service]
Type=simple
Restart=always
User=iulian
ExecStart=/home/iulian/server/start.sh
WorkingDirectory=/home/iulian/server/

[Install]
WantedBy=multi-user.target

Offline

#2 2022-10-14 12:59:40

jonno2002
Member
Registered: 2016-11-21
Posts: 870

Re: Can you give input to systemd services ?

simple answer is no, all systemd is doing is running your script which starts the server, you still have to interface with the game server as normal.

Offline

#3 2022-10-14 13:12:37

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: Can you give input to systemd services ?

Actually the simple answer is yes, you can pass a single argument to service files designed to accept one:

man systemd.service wrote:

It is possible for systemd services to take a single argument via the "service@argument.service" syntax. Such services are called "instantiated" services, while the unit definition without the argument parameter is called a "template". An example could be a dhcpcd@.service service template which takes a network interface as a parameter to form an instantiated service.  Within the service file, this parameter or "instance name" can be accessed with %-specifiers. See systemd.unit(5) for details.

But depending on the goals, it may be better to use a config file that is read when the service is (re)started.  This file could be edited as needed prior to restarting.  Reflector is one tool / package I know off the top of my head that does this.

Last edited by Trilby (2022-10-14 13:14:25)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2022-10-14 13:19:12

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,657
Website

Re: Can you give input to systemd services ?


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#5 2022-10-14 13:19:14

jonno2002
Member
Registered: 2016-11-21
Posts: 870

Re: Can you give input to systemd services ?

hes talking about interfacing with a running server though, at least thats how i read it

EDIT: too slow, yip rcon sounds good, remember using that for cs 1.5 server years ago

Last edited by jonno2002 (2022-10-14 13:22:31)

Offline

#6 2022-10-14 13:38:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: Can you give input to systemd services ?

In that case the question has nothing to do with systemd services.  If the question is "can you give input to a process started by systemd" then the answer is still "yes", but it entirely depends on whether or not said process actually accepts any input - but that has nothing to do with systemd services.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2022-10-14 16:24:19

Iulian
Member
Registered: 2019-08-01
Posts: 27

Re: Can you give input to systemd services ?

yes i want to give input to a server that is started by systemd

Offline

#8 2022-10-14 16:27:50

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: Can you give input to systemd services ?

But the fact that the server was / is started by a systemd service has no relevance on that question.  The answer is no different than if it were started via another service manager, or manually on the command line.  If the question is "can I send commands to a running minecraft server" then it looks like Schard's answer is right on point - but if more input is needed, adjusting your title to highlight the actual question may be helpful.  You don't need help with systemd services, you need help with a minecraft server.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB