Auto Re-Open server after global save

kennyubuntu

Member
Joined
May 20, 2016
Messages
96
Best answers
0
Reaction score
5
How to make it on ubuntu:

- when global save (7:00)
- restart the ubuntu machine
- and re open server

What is the best way?

Code:
[6:55:03.589] > Broadcasted message: "Server is going down for a global save within 5 minutes. Please logout.".
[6:57:03.590] > Broadcasted message: "Server is going down for a global save within 3 minutes. Please logout.".
[6:59:03.590] > Broadcasted message: "Server is going down for a global save in one minute, please logout!".
[7:0:03.791] PLAYERS has logged out.
[7:0:04.181] > Saving server...
[7:0:05.537] > SAVE: Complete in 1.356 seconds using relational house storage.
[7:0:05.987] Preparing to shutdown the server- done.
[email protected]:~/Documentos/server$ ./tfs
 
Last edited:

Marcus

User.postCount++;
Joined
Nov 14, 2015
Messages
1,084
Best answers
10
Reaction score
341
Location
Sweden
while true; do ./tfs; done (instead of only ./tfs)
will restart it until you make Ctrl+C
 
OP
kennyubuntu

kennyubuntu

Member
Joined
May 20, 2016
Messages
96
Best answers
0
Reaction score
5
make a "bat auto restarter" is one way then make it run it automatically.
Bat on linux? Its work?

while true; do ./tfs; done (instead of only ./tfs)
will restart it until you make Ctrl+C

No time conditional? Where i supossed to paste it? And how to restart?

Make it so it saves without shutting down the server?
To all be light, when i restart the machine and restart the server all will be clean (computer and server)
 

Marcus

User.postCount++;
Joined
Nov 14, 2015
Messages
1,084
Best answers
10
Reaction score
341
Location
Sweden
when you run your OT you write ./tfs
but instead of writing that, you write this (entire line, exactly as I wrote it):
while true; do ./tfs; done
 

tokenzz

:thinking:
Joined
Feb 2, 2013
Messages
783
Best answers
2
Reaction score
313
oh, linux didn't see :p. Should work though bad workaround I guess
 
Joined
Sep 3, 2011
Messages
3,688
Best answers
19
Reaction score
2,343
Location
Sweden
- when global save (7:00)
- restart the ubuntu machine
- and re open server
The best way IMO to achieve this would be to setup a Cron Job that runs a shell script after reboot.

Add this to Cron Jobs:
Code:
@reboot /path/to/dir/restarter.sh
Create a file named restarter.sh at the path you set in Cron Jobs then write this in the file:
Code:
while true; do ./tfs; done
Now everytime the dedicated server starts it will run the restarter.sh.

To be able to restart the dedicated server itself you can setup a Cron Job aswell on a certain time.
Code:
0 7 * * * /sbin/shutdown -r now
The first number in this case 0 is minutes.
The second number in this case 7 is hours.
The stars (*) means every day of every month.

With this Cron Job the server will reboot at 07:00.
 
OP
kennyubuntu

kennyubuntu

Member
Joined
May 20, 2016
Messages
96
Best answers
0
Reaction score
5
The best way IMO to achieve this would be to setup a Cron Job that runs a shell script after reboot.
Code:
while true; do ./tfs; done
This is not an infinite loop?
infinite loop will take a little unnecessary processing
I can not make variable

For exemple:
Code:
check if ot is open
else
cd /home/kenny/Documentos/server
./tfs;
---------------------------------------------------

This 2 i need do on Linux command terminal after put my 'restart.sh'
In /home/kenny/Documentos/server/restart
Right?

Code:
@reboot /home/kenny/Documentos/server/restart/restarter.sh
Code:
5 7 * * * /sbin/shutdown -r now
I dont need install nothing? How to remove after? I will test it on my ubuntu desktop, i dont have a VPS yet
 
OP
kennyubuntu

kennyubuntu

Member
Joined
May 20, 2016
Messages
96
Best answers
0
Reaction score
5
No you don't need to install anything Cron Jobs is already in the OS.

What do you want to remove after?
Oh ty, i didn't know it

I told about remove, to remove the task
Cause i will test in my main computer (my ubuntu desktop) after when i get my host i will put there


Did u know answer my others questions?
Code:
while true; do ./tfs; done
This is not an infinite loop?
infinite loop will take a little unnecessary processing
I can not make variable

For exemple:
Code:
check if ot is open
else
cd /home/kenny/Documentos/server
./tfs;
---------------------------------------------------

This 2 i need do on Linux command terminal after put my 'restart.sh'
In /home/kenny/Documentos/server/restart
Right?

Code:
@reboot /home/kenny/Documentos/server/restart/restarter.sh
Code:
5 7 * * * /sbin/shutdown -r now
I dont need install nothing? How to remove after? I will test it on my ubuntu desktop, i dont have a VPS yet
 

gmstrikker

Active Member
Joined
Jul 30, 2014
Messages
379
Best answers
1
Reaction score
31
I have 3 doublets

1- Restart distro, close the ./tfs and re open
Will give better performance?

2- Restart computer, vps
Will give better performance?

3- Restart distro, close the ./tfs and re open AND Restart computer, vps
Will give better performance?

Why?
 

Shyzoul

Advanced OT User
Joined
Apr 13, 2009
Messages
389
Best answers
8
Reaction score
185
@kennyubuntu infinities loops aren't that bad, you need them some times, if you do a script like you mentioned before, it will only run once and stops, on other hand infinite loop will check every time, if you need that much this piece of performace make a check time by time, (hour by hour?), to do that you need Cron use this syntax.
┌───────────── min (0 - 59)
│ ┌────────────── hour (0 - 23)
│ │ ┌─────────────── day of month (1 - 31)
│ │ │ ┌──────────────── month (1 - 12)
│ │ │ │ ┌───────────────── day of week (0 - 6)
│ │ │ │ │
│ │ │ │ │
*_*_*_*_* command to execute

@gmstrikker it gives just because you clean cached data from ram, thats why real tibia restarts every day, to save cached data to a storage and clean the ram, but you surely don't need to do that, tibia use hundred times more ram than tfs.
 
Last edited:

gmstrikker

Active Member
Joined
Jul 30, 2014
Messages
379
Best answers
1
Reaction score
31
All right here?
Code:
cd /home/nazir/Documentos/server && do./tfs;done
After on linux terminal:
Code:
@reboot/home/nazir/Documentos/server/restart/restarter.sh
Code:
0 6 * * * /sbin/shutdown -r now
Just need do it?
 

Shyzoul

Advanced OT User
Joined
Apr 13, 2009
Messages
389
Best answers
8
Reaction score
185
After on linux terminal:
Code:
@reboot/home/nazir/Documentos/server/restart/restarter.sh
reboot is a string not a path, all strings available are:
@reboot
@yearly
@annually
@monthly
@weekly
@daily
@Midnight
@hourly

example:
@daily /path/to/script.sh

@reboot will run once whenever you startup the system.
 
Joined
Sep 3, 2011
Messages
3,688
Best answers
19
Reaction score
2,343
Location
Sweden
This is not an infinite loop?
infinite loop will take a little unnecessary processing
I can not make variable
This won't affect your performance.

This 2 i need do on Linux command terminal after put my 'restart.sh'
In /home/kenny/Documentos/server/restart
Right?
Place the shell script 'restart.sh' at your desired location and edit the Cron Jobs and you're ready to go.
 

Selenia-Global

Selenia-Global.com
Joined
Jan 21, 2018
Messages
28
Best answers
1
Reaction score
1
Hello Guys.
I write this in the final line to open the server.
./build/tfs
But when it goes to global save it just closes the server (it doesnt re openes it)
should i also write
while true; do ./tfs; ? or while true; do ./build/tfs; ?

Thanks in advance.
 

Punktheedge

New Member
Joined
Jul 2, 2019
Messages
34
Best answers
0
Reaction score
1
The best way IMO to achieve this would be to setup a Cron Job that runs a shell script after reboot.

Add this to Cron Jobs:
Code:
@reboot /path/to/dir/restarter.sh
Create a file named restarter.sh at the path you set in Cron Jobs then write this in the file:
Code:
while true; do ./tfs; done
Now everytime the dedicated server starts it will run the restarter.sh.

To be able to restart the dedicated server itself you can setup a Cron Job aswell on a certain time.
Code:
0 7 * * * /sbin/shutdown -r now
The first number in this case 0 is minutes.
The second number in this case 7 is hours.
The stars (*) means every day of every month.

With this Cron Job the server will reboot at 07:00.

How do I access cron?
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,668
Best answers
202
Reaction score
1,376
Location
Norway, Oslo
Hello Guys.
I write this in the final line to open the server.
./build/tfs
But when it goes to global save it just closes the server (it doesnt re openes it)
should i also write
while true; do ./tfs; ? or while true; do ./build/tfs; ?

Thanks in advance.
After you compile tfs (you get build/tfs), you should move the tfs file outside of the build folder (so it is in the same folder/directory as config.lua).
And then use the loop command.

while true; do ./tfs; done

Is basically Linux/shell shorthand for this:
Lua:
while true == true do
  os.execute(_DIR_ .. '/tfs')
end
The execution of the tfs binary isn't done until the server either shutdown or crashes, and since true will always be true, the while condition will continue to execute infinitely. So every time the server crashes or shuts down, it will just start it again.

@kennyubuntu

There is no uneccesary processing here, as it will only continue the script after tfs is done executing. It doesn't loop 1000+ times a second, only once every crash/shutdown.
 
Top