Linux .sh script to start server

Habilis

New member
Messages
225
Points
0
Age
36
Location
Montreal, Canada
IRC Nickname
Habilis
Emulator
I wrote a little script 

that would start server on the background and would write console logs

to 

/home/hercuser/logs/ServerStartup<DAY-TIME>.dat

#!/bin/bash

# ARGUMENT CONSTANTS
START="start"
STOP="stop"
RESTART="restart"

#path to CD
PATHCD="/home/hercuser/Hercules"

# Path to the executable.
EXE="./athena-start"

# Date and representation logic
DATE="$(which date)"
TIMESTAMP=`$DATE '+%Y-%m-%d_%H_%M'`

# Path to the logfile that will hold log of the server up.
LOG="/home/hercuser/logs/ServerStartup$TIMESTAMP.dat"
cd $PATHCD
# Server logging
case "$1" in
"$START" | "$RESTART")
echo "$($EXE $1)" &> "$LOG" 2>&1 &
;;
"$STOP")
$($EXE $1)
;;
*)
;;
esac


here is the exemple of file

ServerStartup2016-06-25_10_48.dat

Code:
[...]

[Status]: Cleaning up maps [866/875]: moro_cav...
[Status]: Cleaning up maps [867/875]: 1@dth1...
[Status]: Cleaning up maps [868/875]: 1@dth2...
[Status]: Cleaning up maps [869/875]: 1@dth3...
[Status]: Cleaning up maps [870/875]: 1@rev...
[Status]: Cleaning up maps [871/875]: 1@xm_d...
[Status]: Cleaning up maps [872/875]: 1@eom...
[Status]: Cleaning up maps [873/875]: 1@jtb...
[Status]: Cleaning up maps [874/875]: c_tower2_...
[Status]: Cleaning up maps [875/875]: c_tower3_...
[Status]: Cleaned up 875 maps.
[Status]: Close Map DB Connection....
[Status]: Close Log DB Connection....
[Status]: Finished.
[Info]: Memory manager: No memory leaks found.
 
Last edited by a moderator:
If stop command used, only then the file with the log is released. everything is logged...

Need to see about the memory now since that's a pretty big log file...

 
Back
Top