I have a dedicated box running debian 8.1 x64 and need a service or something that lets me run a server and close the SSH session and the server stays running.
I run a script here: /home/arma3server/serverfiles/public/start.sh to run the game server.
I need a way to start and run the server from an SSH connection that I can close and have the server stay running.
So, the server would need to run in a background process.
Debian 8.1 uses systemd. I tried to create a service but it failed.
I don't know much about systemd scripts, but if you want to run a command or script from ssh then close the terminal while the command continues to run the the background just put a & at the end.
so you'd run:
That did not work. I ran it and exited then logged in via a different machine and ran top and the server was not running
nohup script &.
For most commands, if you run them in the background using the
& after the command, they will terminate when the terminal is closed. This is because the os sends the SIGHUP (hang up) signal to background jobs when a terminal closes, and most programs terminate on receipt of this signal.
nohup means no hang up.
that seems to work. thanks
would someone mind writing a systemd service or something that will autostart the script for me when the server reboots?
Using systemd is probably the best way of doing it but as an alternative you can run
crontab -e and add
@reboot /home/arma3server/serverfiles/public/start.sh That will run the script when the server turns on.
Description=Run arma server
ExecStart=nohup /home/arma3server/serverfiles/public/start.sh &
Save it in /etc/systemd/system/
To improve upon that a bit:
Description=Arma 3 Server
We want to make sure the network is up and running, and it should now restart automatically if it crashes.
Have a look here for more info on how systemd unit files work. This article is in no way complete, but it should be helpful.
@spidernet You shouldn't need nohup or the & symbol on the ExecStart because those are important only to keeping the process running if you've started it directly from your SSH session. If systemd starts it, you don't need to worry about the hangup signal, or running in background, as systemd handles making it a daemon.
Always glad to help.
@LinuxMaster9 I don't have the arma server files, so I can't guarantee 100% that this unit file will work. Just let us know if there's a problem with it.
This will also come in handy. Maybe....
thats what i use.
screen -dmX [session name] [script to run]
i have tried to use screen but it never worked. For some reason tmux worked though.
My start script was a buggerbear to make work too. id almost say it was the hardest bash script i have made so far.
Keep in mind that the code I am about to post is lean and works. It went through about 3 hours of tweaking since I couldnt get the mods to load and stuff. Very irksome. Im going to have a hell of a time setting up the Headless clients that will run with the server.
./arma3server -netlog -port="2302" -cfg="/home/arma3server/serverfiles/public/serverconfig/basic.cfg" -config="/home/arma3server/serverfiles/public/serverconfig/server.cfg" -mod=mods/\@ace3\;mods/\@cba_a3\;mods/\@ALiVE\; -servermod=mods/\@AliveServer -bepath="" -autoinit -world=empty -noSound -loadmissiontomemory
plus, I have to figure out how to assign the processes to threads automatically. I miss a GUI. I wish I could RDP into the server with a GUI and do this like on Windows Server.
Sad I know. I have been spoiled by Windows server.
I keep thinking about VNC or something but........
The server specs I have are:
CPU: Intel Xeon E3 1245v2
Cores/Threads: 4 cores / 8 threads
Frequency: 3.4 Ghz+
RAM: 32GB DDR3
Disks: 3x 120GB SSD RAID 1
Network Connection: 1 Gbps
Failover IP: up to 16
Backup Space: 100GB
Datacenter location: BHS Canada.
Hosting company: OVH via SoYouStart
You can open graphical programs over ssh using x forwarding. Just do
ssh -X [email protected] command this will launch the gui for the program on your ssh client.
EDIT: If it's a VPS that probably won't work.
Not to mention that the ssh client has to be a Linux one. Don't think Windows supports GUI redirect
It is a dedicated server box
You're correct, Windows typically does not, but I remember seeing a way to do it with cygwin.
There should be a way to assign affinity with the command line options, try running the actual server file with
--help as an argument. That may shed some light on options you can use.