WebFaction
Community site: login faq

Today the webservers were updated, so when they got back up I found out that I had to manually restart my TeamSpeak server. I was wondering if there was a way of getting the script to automatically run after a restart, since my clients wouldn't necessarily like to wait on me to be available to manually boot it.

asked 28 Oct '16, 03:32

iambryan
156
accept rate: 0%


Cron has a special directive called @reboot, which will trigger your script only once, just after the server reboots.

Your cron task should be as simple as:

@reboot /path/to/the/script

You can mix this with a script like the one here too!

permanent link

answered 28 Oct '16, 06:07

iliasr ♦♦
2.1k14
accept rate: 35%

Thanks for the response! I'm not too familiar with cron/scripting in general. What exactly do I do with this @cron line? Currently, whenever I need to boot my script, I just copy and paste these lines into shell:

YOUR_IP=(my ip)

ARCH=x86; [ "$(uname -i)" = x86_64 ] && ARCH=amd64 
(crontab -l; echo "*/20 * * * * ~/teamspeak3/ts3server_startscript.sh start 'voice_ip=$YOUR_IP filetransfer_ip=$YOUR_IP query_ip=$YOUR_IP' >>~/logs/user/teamspeak.log 2>&1 &") | crontab 
~/teamspeak3/ts3server_startscript.sh start "voice_ip=$YOUR_IP filetransfer_ip=$YOUR_IP query_ip=$YOUR_IP"

I'm guessing I can turn this into a bash script that auto executes? I really don't know what I'm doing, haha.

(28 Oct '16, 06:59) iambryan

The third line of the script you've pasted should add a command to start your service via cron every 20 minutes. So, no further action is actually needed, as it should start within 20 minutes of the server booting.

That said, you could try adding the first, second and last lines within the if section on the script I've pointed you in my answer.

(28 Oct '16, 10:04) iliasr ♦♦

Ah, thanks! I've just changed it to 5 now since 20 minutes is a very long time (for my clients haha).

(28 Oct '16, 15:03) iambryan
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×97
×25
×3

question asked: 28 Oct '16, 03:32

question was seen: 1,162 times

last updated: 28 Oct '16, 15:04

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM