• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OpenTibia [Windows] Server auto restarter

Infernum

Senator
Joined
Feb 14, 2015
Messages
5,643
Solutions
559
Reaction score
3,949
Requirements: Python 3.5, psutil package (use pip install psutil to install)
Instructions: Copy the below code into a new python script and save it to the same directory where your server executable is located
Python:
import psutil # DEPENDENCY: pip install psutil
import os
import time
from threading import Timer

PROCESS_NAME = "theforgottenserver.exe"
CHECK_INTERVAL = 3.0

def process_exists():
    for process in psutil.process_iter():
        if process.name() == PROCESS_NAME:
            return True
    return False

def check_server():
    if not process_exists():
        os.startfile(PROCESS_NAME)
        timestamp = time.strftime("%a, %d %b %H:%M:%S", time.localtime())
        print("{} | Notice: {} started (process not found)".format(timestamp, PROCESS_NAME))
    timer = Timer(CHECK_INTERVAL, check_server)
    timer.start()

check_server()
 
We use to do this in DOS... No need to install anything.. Of course i don't use Windows anymore so i don't remember how it is done.
 
Is very powerful script, like python, where you can do almost everything.

But like the friends above said, such a script can be done using Bash and PowerShell in just 3-4 lines.

Anyways, big thanks! Awesome script.

Do you know Python in such advantage form? I understand: "def" is like "function" in php and lua, right?

Looks very promising. I like to learn new languages. I think python will be my next.

Cheers ;)
 
We use to do this in DOS... No need to install anything.. Of course i don't use Windows anymore so i don't remember how it is done.
Is very powerful script, like python, where you can do almost everything.

But like the friends above said, such a script can be done using Bash and PowerShell in just 3-4 lines.

Anyways, big thanks! Awesome script.

Do you know Python in such advantage form? I understand: "def" is like "function" in php and lua, right?

Looks very promising. I like to learn new languages. I think python will be my next.

Cheers ;)
sorry the dumb question have to use both or can only use the bash?
:start
theforgottenserver.exe
goto start
 
Back
Top