So I created a few scripts to help manage automatic rebooting of servers and machines. This is what I did:
as root, I editted /etc/crontab to include three lines:
Code:
00 6 * * 0,2,3,4,5,6 gamer /home/gamer/start.sh
00 6 * * 1 root /usr/bin/reboot
@reboot gamer /home/gamer/start.sh
The first line says that at 6:00 on Sundays, Tuesdays, Wednesdays, Thursdays, Fridays, and Saturdays, it should execute a script I made called start.sh (this will be posted further along).
The second line says that at 6:00 every Monday morning, the server needs to reboot.
The third line says that when it reboots, the server needs to execute that start.sh script.
In my home directory, I put start.sh
Code:
#!/bin/bash
/home/gamer/cstrike/aim/aim.sh
sleep 120
/home/gamer/cstrike/chill/chill.sh
sleep 120
/home/gamer/cstrike/custom/custom.sh
sleep 120
/home/gamer/cstrike/practice/practice.sh
sleep 120
/home/gamer/cstrike/private/private.sh
sleep 120
/home/gamer/cstrike/pub/pub.sh
sleep 120
/home/gamer/cstrike/pug/pug.sh
sleep 120
/home/gamer/czero/bones/bones.sh
sleep 120
/home/gamer/czero/survivor/survivor.sh
sleep 120
/home/gamer/tf2/cp/orangebox/cp.sh
sleep 120
/home/gamer/tf2/pl/orangebox/pl.sh
sleep 120
/home/gamer/tf2/vanilla/orangebox/vanilla.sh
sleep 120
/home/gamer/gmod/orangebox/gmod.sh
exit 0
This script says that I need to execute a number of scripts (one for each server), with 2 minutes of wait time in between each execution. Each line points to the script for each server.
Here is an example of a startup script for one individual server (eg, aim.sh). Make sure to place this script in the directory from which you launch your server (or make sure your script directs you there).
Code:
#!/bin/bash
screen -X -S aim quit
sleep 10
cd /home/gamer/cstrike/aim
/usr/bin/screen -dmS aim ./hlds_run -game cstrike +ip 70.34.195.6 +port 27015 +map aim_map -autoupdate +maxplayers 21 -pingboost 1