Jump to content
  • 0
Habilis

Linux .sh script to start server

Question

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

[...]

[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.
Edited by Habilis

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

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...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.