Find the answer to your Linux question:
Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 11 to 20 of 36
Moved thread to servers forum....
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Administrator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,864

    Moved thread to servers forum.
    I do not respond to private messages asking for Linux help, Please keep it on the forums only.
    All new users please read this.** Forum FAQS. ** Adopt an unanswered post.

    I'd rather be lost at the lake than found at home.

  2. #12
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    give this a try. it ought to be able to find the TS server, if running, and if not, start it up properly.

    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/ts3
    sh ./ts3s.sh
    rc=$?
    if [ $? -eq 0 ]; then
      echo OK
    else
      echo FAILED
    fi
    
    exit $rc
    once you've created this script, made it executable, and tested it, you can make it a cron job.

  3. #13
    Linux Newbie
    Join Date
    May 2012
    Posts
    115
    so its like:

    Code:
    nano /bin/bash
    thant add this command:
    Code:
    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/ts3
    sh ./ts3s.sh
    rc=$?
    if [ $? -eq 0 ]; then
      echo OK
    else
      echo FAILED
    fi
    
    exit $rc

    is that right?

  4. #14
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    no, the first part of your command would open the /bin/bash binary in nano. not a lot of goodness there. you want to pass the name of a file that will be your cron script to the editor, e.g.:
    Code:
    nano /tmp/ts-cron.sh
    then put all that other code into it.

    also, at the top of the script, put this on the very first line:
    Code:
    #!/bin/bash
    this tells the script what command interpreter to use, if run with via "./" (as opposed to specifically calling it with the interpreter, e.g.: bash /tmp/ts-cron.sh).

    also, make sure it is executable, e.g.:
    Code:
    chmod +x /tmp/ts-cron.sh

  5. #15
    Linux Newbie
    Join Date
    May 2012
    Posts
    115
    ive done every thing:

    Code:
    [joaogl@localhost ~]$ nano /tmp/ts-cron.sh
    [joaogl@localhost ~]$ chmod +x /tmp/ts-cron.sh
    [joaogl@localhost ~]$
    and in the file is this:

    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/ts3
    sh ./ts3s.sh
    rc=$?
    if [ $? -eq 0 ]; then
      echo OK
    else
      echo FAILED
    fi
    
    exit $rc
    and as you can see:

    Code:
    [joaogl@localhost ~]$ chmod +x /tmp/ts-cron.sh
    [joaogl@localhost ~]$
    so.... some things is roung i think

  6. #16
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by Joaogl View Post
    so.... some things is roung i think
    that all looks good, why do you say something is wrong? we have not set up cron to run it yet, if that is what you mean.

    first, run it from the command line, as a test - to make sure that it works. run it like this:
    Code:
    cd /tmp
    ./ts-cron.sh
    report the output of the command here.

  7. #17
    Linux Newbie
    Join Date
    May 2012
    Posts
    115
    now i think is wrong

    Code:
    [joaogl@localhost tmp]$ ./ts-cron.sh
    Could not locate binary file, aborting

  8. #18
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    okay, you've either got to put your ts-cron.sh script in the same directory where the binary is located, or hard-code the path to the binary in the script.

    let's do the former. so if the binary is in the path /home/joaogl/Documents/ts3/ts3 (which i think it is, but you should know), then do:

    Code:
    mv /tmp/ts-cron.sh /home/joaogl/Documents/ts3/ts3/
    then run the script, e.g.:

    Code:
    cd /home/joaogl/Documents/ts3/ts3
    ./ts-cron.sh
    is that better?

  9. #19
    Linux Newbie
    Join Date
    May 2012
    Posts
    115
    ok now its fine:

    Code:
    [joaogl@localhost ts3]$ ./ts-cron.sh
    TeamSpeak binary: ts3server_linux_x86
    TeamSpeak is not running
    Starting TeamSpeak: Usage: ./ts3s.sh {start|stop|restart|status}
    OK
    [joaogl@localhost ts3]$

    now to test this can i just do: sh ts3s.sh stop and it will open again?

  10. #20
    Linux Newbie
    Join Date
    May 2012
    Posts
    115
    actually it didnt work but i've already fix it:


    Code:
    [joaogl@localhost ts3]$ ./ts-cron.sh
    TeamSpeak binary: ts3server_linux_x86
    TeamSpeak is not running
    Starting TeamSpeak: Starting the TeamSpeak 3 server
    TeamSpeak 3 server started, for details please view the log file
    OK
    [joaogl@localhost ts3]$

    Code:
    [joaogl@localhost ts3]$ ./ts-cron.sh
    TeamSpeak binary: ts3server_linux_x86
    TeamSpeak (pid 11756) is running

    just becouse of that
    Code:
    printf "Starting TeamSpeak: "
    cd /home/joaogl/Documents/ts3/ts3
    sh ./ts3s.sh start
    rc=$?
    if [ $? -eq 0 ]; then

Page 2 of 4 FirstFirst 1 2 3 4 LastLast

Posting Permissions

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