I'm trying to get my system.service file to run a command that is inside my start
script. I've tried adding StandardInput=
which did not work, so I believe I misunderstood how that operates. I've also tried the following unit below:
This fails, of course. How would I execute the command ./start start
?
Description=Service File
Wants=network-online.target
After=syslog.target network.target nss-lookup.target network-online.target
[Service]
User=host
WorkingDirectory=/home/host/Server/
ExecStart=/home/host/Server/start start
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
start.sh
and it executes three functions, Start, Stop, Compile. I want it to dostart
. – Lex King Dec 19 '23 at 22:00./start start
I can get everything green lit. If I try to run the command ./start.sh start it will throw the following error:/home/host/Server$ ./start.sh start
bash: ./start.sh: No such file or directory
It runs scripts inside that start file to initialise the servers activating and connecting the 3 ports of the game. I got each of these 3 services on their own individual files to be enabled at startup. – Lex King Dec 24 '23 at 11:55/home/host/Server
, not the actual root directory/
. So you have an executable file/home/host/Server/start
, ie. an executable file namedstart
which lies in the directory/home/host/Server
of your server. But you also have a file namedstart.sh
? In which directory does that lie? Is it executable too? What is the difference between the two? Please be a bit more forthcoming with information about your environment. Bear in mind that I cannot see what's on your server. – Tilman Dec 24 '23 at 14:02Server
folder. I've attached an image in the link below to show the file. It seems to be a standard script and executes as it should, for the last 10+ years. https://i.imgur.com/z4VVJm9.pngWhat I need it to do is execute a command, or function, "start" when the system.service file is enabled.
– Lex King Dec 24 '23 at 14:40ExecStart=/home/host/Server/start start
This does not work. Is there a way to run a function like this in a system.service file?start
, notstart.sh
. You may want to edit your question to fix that. As to running it from a systemd unit, your approach is basically correct and should work. So it remains to diagnose why it doesn't work in your case. I cannot say anything specific without knowing what's actually inside yourstart
file, but generally speaking you would inspect relevant log files to find out what's going wrong. – Tilman Dec 25 '23 at 11:28systemctl status name.service
wherename.service
is your unit's file name? – Raffa Dec 25 '23 at 14:39