Forum

Results 1 to 8 of 8
  1. #1
    Join Date
    December 2009
    Location
    NLD
    Posts
    5

    Background Process Without Root?

    Edit by mod
    Please don't use this outdated script anymore! The script got an overhaul long time ago.
    Please use the minimal or startscript instead


    Dear TS community,

    I am running TS3 on a VPS without root access (I have a user account). I always ran TeamSpeak 2 without problems, just with the ./ts2 -start command or whatever it was..

    Now with TS3 there is no such option? I've searched the forums and only found start scripts that need root etc, and I am no Linux expert.. I do not need a script that starts the server after a reboot or something, the uptime is great and never used anything like that with TS2. I can start the server myself once a year

    When I start the TS3 server now it puts everything into the console, not in the background, so when I close my shell, the server shuts down also, this forces me to leave my PC and shell on/open to keep TS running?

    So in short..
    - TS3 runs fine.
    - No root access for start scripts, just shell access.
    - How can I start the server in the background so I can close my shell?

    Version: 3.0.0-beta11 [Build: 9559]
    Platform: Linux
    Max Clients: 512

    Thanks in advance!
    Last edited by dante696; March 3rd, 2011 at 10:25 AM.

  2. #2
    Join Date
    March 2005
    Location
    Germany
    Posts
    50
    start:
    Code:
    ./ts3server_linux_amd64 &
    stop:
    Code:
    killall ts3server_linux_amd64

  3. #3
    Join Date
    December 2009
    Location
    Ukraine
    Posts
    21
    man bash
    If a command is terminated by the control operator &, the shell exe-
    cutes the command in the background in a subshell.
    1. you can just add '&' without quotes to the end of command line
    2. you can run server in screen (not really necessary for ts3)
    3. you can search this forum for startup scripts.

    PS: woops, looks like Hitme kinda faster than me :]

  4. #4
    Join Date
    December 2009
    Location
    NLD
    Posts
    5
    Thanks for the fast responses guys

    It does launch the server alright, I used the "./ts3server_linux_x86 inifile=ts3server.ini &" command like u guys told me, with success, it starts the server and returns me to the command line a few seconds later.

    When I check the processes with ps x it does show the process and everything runs fine, although when I close the shell than, the proces still quits? Never had this with TS2..

    I have unlimited processes so that aint the issue, it just misses some kind of deamon I guess?

  5. #5
    Join Date
    March 2005
    Location
    Germany
    Posts
    50
    i habe no clue but maybe you have to tyr screen then.

    use forums search about it it will turn out a lot.

    edlit:
    screen -A -m -d -S ts3 [ROOT TO TS]/ts3server_linux_86

  6. #6
    Join Date
    December 2009
    Location
    NLD
    Posts
    5
    Quote Originally Posted by Hitme View Post
    i habe no clue but maybe you have to tyr screen then.

    use forums search about it it will turn out a lot.

    edlit:
    screen -A -m -d -S ts3 [ROOT TO TS]/ts3server_linux_86
    I installed screen but there where so many options so I looked further, didnt see your reply yet at that time..

    I've used NOHUP (?) now, at it worked like a charm in combination with your & trick. I've closed the shell and TS3 is still running, so I am happy

    http://en.wikipedia.org/wiki/Nohup

    I've stored the commandline u provided from screen though, perhaps its better

    Thanks again for your support!

  7. #7
    Join Date
    December 2009
    Location
    Ukraine
    Posts
    21
    Quote Originally Posted by RVN2010 View Post
    II've stored the commandline u provided from screen though, perhaps its better

    Thanks again for your support!
    it is better when you running an application with interactive console and you need to interact with it, so you can login via ssh, attach screen, do whatever you want in appl's console, detach screen and logout.

    in other case some people dislike using 'tail -f' to get access to realtime logs output, and they are using screen just to see whats going on out there

    this is just my opinion.

  8. #8
    Join Date
    December 2009
    Location
    New Jersey USA
    Posts
    77
    Make sure you set your basedir=

    Then add this to your bootup and shutdown action

    Code:
    #!/bin/sh
    # description: Start and Stop the Server
    # chkconfig: 2345 99 00
    
    case "$1" in
    'start')
    	#!/bin/bash
    	#
    	# option support added
    	#
    	# Universal start/stop script 
    	#
    	# Script Version: 0.4.2
    	#
    	# ! awk needs to be installed !
    	# 
    	# !! WARNING !!
    	# I am not responsible for damage caused by misconfigurations  
    	# to your installation or any other damage that may occure.
    	#
    	# Info:
    	# This script is made by Bennie van Lent <[email protected]>
    	#
    	# Support:
    	# comment on my blog or mail 
    	#
    	# Read the INSTALL file for more info about this script and ways
    	# to install it in crontab.
    	#
    	# Script is universal for different linux distro's
    	# this is done on purpose to make it easy to use 
    	# and portable. We are NOT using start/stop daemon
    	# tools written for each distro e.g. start-stop-daemon
    	# on Debian.
    	#
    	# Vars
    	# basedir = prog install directory without trailing slash!
    	# progbin = name of the server executable
    	# progopt = commandline options
    	# proglog = name and path of the logfile
    	#
    	# Use different names for each session for easy use.
    	#
    	# Tested on:
    	# Debian
    	# CentOS 4.4
    	# Ubuntu
    	#
    	###################################################
    	#
    	#Config these setting according to your setup.
    	basedir="/usr/local/games/teamspeak3-server_linux-x86"  
    	progname="Teamspeak 3"
    	progbin="ts3server_linux_x86"
    	proglog="${basedir}/ts3.log"
    	options="inifile=ts3server.ini"
    	progopt =""
    	##################################################
    	# NO CHANGES BELOW. ELSE ITS ON YOUR OWN RISK
    	#
    	realbin="${basedir}/${progbin}"
    	cd ${basedir}
    	# Checking if ut3 is there and executable
    	if [ -f "${basedir}/${progbin}" ]; then
    		if [ ! -x "${basedir}/${progbin}" ]; then
    			echo -e "${progbin} file is not executable"
    			echo -e "Please fix this and try again"
    			exit 2
    		fi
    	else
    		echo "cannot find ${progbin}!"
    		echo "If this is not correct edit the start script"
    		exit 2
    	fi
    	
    	case "$1" in 
    		start)
    		echo -n "Starting $progname dedicated server: "
    		if ps -ef |grep "${realbin}"|awk -F" " -v prog=${realbin} 'BEGIN {status=1} ; $8 == prog {status=0} ; END {exit status}' ; then
    			echo -e "already active"
    			exit 0	
    		else
    			if [ -f "${proglog}" ]; then
    				cp ${proglog} ${proglog}.crash
    			fi
    			if ${basedir}/${progbin} ${options} 1>> ${proglog} 2>&1 & sleep 3 ; then
    				pid=`ps -ef |grep "${realbin}"|awk -F" " -v prog=${realbin} 'BEGIN {status=1} ; $8 == prog { print $2 } ; END {exit status}'`
    				if ps h ${pid} >/dev/null; then
    	         			echo -e "....Started!"
    					exit 0	
    		      		else
    	      				echo -e "....Failed to start. Check logfile or run in debug!"
    					exit 1
    	      			fi
    			else
    				echo -e "Failed"
    			fi
    		fi
    	;;
    	stop)
    		echo -n "Stopping $progname dedicated server: "
    		if ! ps -ef |grep "${realbin}"|awk -F" " -v prog=${realbin} 'BEGIN {status=1} ; $8 == prog {status=0} ; END {exit status}' ; then
    			echo -e "server not running or crashed."	
    		else
    			pid=`ps -ef |grep "${realbin}"|awk -F" " -v prog=${realbin} 'BEGIN {status=1} ; $8 == prog { print $2 } ; END {exit status}'`
    			kill -9 ${pid}
    			if ! ps -ef |grep ${basedir}/${progbin}|awk -F" " -v prog=${basedir}/${progbin} 'BEGIN {status=1} ; $8 == prog {status=0} ; END {exit status}' ; then
    				echo -e "stopped"
    				exit 0
    			else
    				echo -e "unable to stop server or server crashed"
    			fi
    		fi	
    	;;
    	status)
    		echo -n "`date +"%Y-%m-%d %H:%M:%S"` Checking $progname dedicated server status: "
    		if ! ps -ef |grep "${realbin}"|awk -F" " -v prog=${realbin} 'BEGIN {status=1} ; $8 == prog {status=0} ; END {exit status}' ; then
    			echo -e "server not running or crashed... Restarting"	
    			$0 start
    		else
    			echo -e "Server still running."
    		fi
    	;;	
    	check)
    	        echo -n "Checking $progname dedicated server status: "
    		if ! ps -ef |grep "${realbin}"|awk -F" " -v prog=${realbin} 'BEGIN {status=1} ; $8 == prog {status=0} ; END {exit status}' ; then
    	                echo -e "offline"
    	        else
    	                echo -e "online"
    	        fi
    	;;
    	restart)
    		echo -e "Restarting $progname dedicated server... "
    		$0 stop && $0 start
    	;;
    	debug)
    		echo -n "Starting debug mode for $progname dedicated server: "
    		if ps -ef |grep "${realbin}"|awk -F" " -v prog=${realbin} 'BEGIN {status=1} ; $8 == prog {status=0} ; END {exit status}' ; then
    	   		echo -e "already active"
    			exit 3	
    		else
    			echo "--DEBUG will appear on screen!"
    	   		echo "--Hit CTRL+C to kill the server!"
    			${basedir}/${progbin} ${options}
    		fi
    	;;
    	*)
    	   echo "Usage: $0 {start|stop|restart|status|check|debug}"
    	   exit 1
    	esac
    	touch /var/lock/subsys/Teamspeak_3
    	;;
    'stop')
    	rm -f /var/lock/subsys/Teamspeak_3
    	;;
    *)
    	echo "Usage: $0 { start | stop }"
    	;;
    esac
    exit 0

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 8
    Last Post: March 9th, 2015, 10:58 PM
  2. Replies: 0
    Last Post: May 4th, 2011, 02:22 AM
  3. [outdated] Linux Server - Background Process?
    By ReiserFS in forum Linux / FreeBSD
    Replies: 4
    Last Post: December 20th, 2009, 02:17 AM

Posting Permissions

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