Find the answer to your Linux question:
Page 4 of 4 FirstFirst 1 2 3 4
Results 31 to 36 of 36
Open the server = to start it; Anti-crash is this i mean the crontab becouse when it goes down it will start again so......
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #31
    Linux Newbie
    Join Date
    May 2012
    Posts
    115

    Open the server = to start it;

    Anti-crash is this i mean the crontab becouse when it goes down it will start again so...

  2. #32
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    if you want to start it, you should just be able to execute the cronjob manually - that is the whole point after all. i don't remember the path, but cd to where the script is located (somewhere in your home dir, i think), and execute it:

    Code:
    ./ts-cron.sh
    i think that was the name of the script. that should start it up, unless the script detects that it is already running. if you created the cronjob, then you should see that log in /tmp/ getting overwritten every 5 minutes, with the output of the script.
    Last edited by atreyu; 05-27-2012 at 04:28 AM. Reason: typo

  3. #33
    Linux Newbie
    Join Date
    May 2012
    Posts
    115
    ITS WORKING!!!!

    THANKS

    THANKS

    THANKS


    just a question now if i want to do this with an other server for example other ts3 server localized in /home/joaogl/Documents/ts3/ts32/


    so in this case we do:


    Code:
    [joaogl@localhost ~]$ nano /home/joaogl/Documents/ts3/ts32/ts2-cron.sh
    [joaogl@localhost ~]$ chmod +x /home/joaogl/Documents/ts3/ts32/ts2-cron.sh
    [joaogl@localhost ~]$
    in the file...

    Code:
    #!/bin/bash
    D1=$(readlink -f "$0")
    BINARYPATH="$(dirname "${D1}")"
    cd "${BINARYPATH}"
    LIBRARYPATH="$(pwd)"
    
    if [ -e "ts3server_linux_x86" ]; then
            BINARYNAME="ts3server_linux_x86"
    elif [ -e "ts3server_linux_amd64" ]; then
            BINARYNAME="ts3server_linux_amd64"
    elif [ -e "ts3server_freebsd_x86" ]; then
            BINARYNAME="ts3server_freebsd_x86"
    elif [ -e "ts3server_freebsd_amd64" ]; then
            BINARYNAME="ts3server_freebsd_amd64"
    else
        	echo "Could not locate binary file, aborting"
            exit 5
    fi
    echo "TeamSpeak binary: $BINARYNAME"
    pid=$(/sbin/pidof -x $BINARYNAME)
    if [ -n "$pid" ]; then
      echo "TeamSpeak (pid $pid) is running"
      exit 0
    else
      echo "TeamSpeak is not running"
    fi
    
    printf "Starting TeamSpeak: "
    cd /home/joaogl/Documents/ts3/ts32/
    sh ./ts3s.sh start
    rc=$?
    if [ $? -eq 0 ]; then
      echo OK
    else
      echo FAILED
    fi
    
    exit $rc

    than

    Code:
    [joaogl@localhost ~]$ chmod +x /home/joaogl/Documents/ts3/ts32/ts-cron.sh
    [joaogl@localhost ~]$
    but know lets see if i can do it...

    Code:
    [joaogl@localhost ~]$ crontab -e
    than


    Code:
    */5 * * * * /home/joaogl/Documents/ts3/ts3/ts-cron.sh > /tmp/tr-cronjob.log 2>&1
    */5 * * * * /home/joaogl/Documents/ts3/ts3/ts2-cron.sh > /tmp/tr-cronjob2.log 2>&1

  4. #34
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Quote Originally Posted by Joaogl View Post
    I
    just a question now if i want to do this with an other server for example other ts3 server localized in /home/joaogl/Documents/ts3/ts32/
    That won't work if the name of the binary is the same as in the other server. is that want you really want - to run two instances of the same server/binary? if that is so (and you are able to run two instances simultaneously), then you can still use this approach, you just have to change how you are getting the PID of the daemon.

    What you could do is use pidof to get the pids of the binaries that are running, then use ps to list just those pids, and grep their output for the path that the scripts reside in - that's how you can tell which server is which.

    here is untested example:
    Code:
    pids=$(pidof <binary_name>)
    for pid in $pids; do
      ps auxww|grep <script_path>
    done

  5. #35
    Linux Newbie
    Join Date
    May 2012
    Posts
    115
    just to know and to stop completly how can i do it? becouse if i stop the server it will start again

  6. #36
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Quote Originally Posted by Joaogl View Post
    just to know and to stop completly how can i do it? becouse if i stop the server it will start again
    heh, yeah that could be annoying. for now, you'll have to stop the cron daemon (as root):
    Code:
    service crond stop
    The reason why this is not ideal is b/c now *all* processes that are controlled by cron will not run, not just your TS server.

    ideally, you could manage this a better. one way would be to remove it from cron and make it a true stand-alone daemon (this is what I'd do). another way (shorter path to completion) would be to use a "control" file (e.g., ~/ts.PAUSE) that your cron script would look for every time it is run, and if it exists - simply exit, instead of starting. then when you want to run the script again, just remove ~/ts.PAUSE and cron will start it up as normal.

Page 4 of 4 FirstFirst 1 2 3 4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •