Linux Setting up your linux gameserver as a service.

This writeup is intended to help those having issues getting 7days to run as a service that automatically starts at startup on Ubuntu linux.

I will later do a write up and hopefully a script to get 7days to run as a sandboxed chroot environment.

For this writeup we will be using Ubuntu server 24.04 LTS. With the free Pro license you get 10 years of server support and 2 more if you want to pay some money.

First we need to define where the server will be installed at. I prefer to create a dedicated user and a home directory. This setup separates things.

First we need to update the server OS to the latest version so we run the commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt update
If you need to update the OS release run this command then run the above commands and then reboot: sudo do-release-upgrade

Now let us add a user to have a custom home folder directory:
useradd 7days

Next we need to download and install 7days by running these commands:

steamcmd
force_install_dir /home/7days/7days <-- If you do not use this option the install will be here: ~/.local/share/Steam/steamapps/common
(note folder must exist for download to show up)
login anonymous <-- you must set install directory before login
app_update 294420 validate
quit

If you fail to use the force_install_dir option, now we are going to rename the folder as spaces in linux names are bad juju:
cd ~/.local/share/Steam/steamapps/common
sudo mv '7 Days to Die Dedicated Server' 7days (mv is really a move command, but it works as a rename as well)
cp 7days /home/7days/

Now you need to add a script to /usr/local/bin
Let us call it 7days.sh
The file will contain the following:
#!/bin/bash
nohup sh /home/7days/7days/startserver.sh -configfile=/home/7days/7days/serverconfig.xml -nographics -dedicated -quit
Paste the above by first running this command:
sudo vi /usr/local/bin/7days.sh
paste in the contents after hitting i for entering insert mode
hit the escape button to exit that mode
hit :
type wq
file is now made and saved with the script details

Now let us make sure the file has execution rights so we run:
sudo chmod +x /usr/local/bin/7days.sh

Now let us start on adding the service
So now we go to /etc/systemd/system
Now we make a file there called 7days.service by invoking:
sudo vi 7days.service
hit i to enter instert mode and paste the following:

[Unit]
Description=My Custom Service

[Service]
Type=simple
ExecStart=/usr/local/bin/7days.sh # Replace with the actual path to your script
Restart=always

[Install]
WantedBy=multi-user.target

Now hit escape
type :
type wq
now enter
sudo chmod +x 7days.service

Now we can engage this as a service and start it:
sudo systemctl enable 7days
sudo systemctl start 7days

Now to check if it is running:
type:
top
you will see the executable at the top of the list
hit q to exit top

You can also check if it is running by typing:
ps -aux | grep 7days
the result should have two results, more if you have more than one instance running

If you need to set the server to reboot daily for whatever reason. We can do that with crontab
sudo crontab -e
add the following:
0 0 * * * service 7days restart (this will restart the service at midnight)
hit ctrl+x to exit
hit y to save changes
 
Note that with this setup the saves folder will default to this folder:
/root/.local/share/7DaysToDie

You will need to uncomment the line UserDataFolder in serverconfig.xml and add the absolute file path to the save file folder.

to copy the folder if you want to activate it and move it to where you can manipulate just do:
sudo systemctl stop 7days
su -
cp -R /root/.local/share/7DaysToDie /home/7days/7days/saves <--makesure the last directory location is specified in serverconfig.xml
 
If you are seeing this error in the output log file in the game folder:

2025-07-05T02:57:07 0.058 WRN The open files limit is too low (1024) and may cause crashes. Recommended is at l
east 10240. Follow these steps to increment it:
- Open /etc/security/limits.conf with a text editor: 'sudo editor /etc/security/limits.conf'
- Add or update the line: 'root soft nofile 10240'
- Save the file and exit the editor
- Apply the changes: Log out and back in or restart the system


You need to add this to the service file for systemd under the [Service] section: (in our case /etc/systemd/system/7days.service)

LimitNOFILE=10240

Then run:
sudo systemctl daemon-reload
sudo systemctl restart 7days

Note that this settings change was the only way I was able to make the error disappear.
 
Back
Top