Rust server automatic start and stop times?
i was wondering if there is a script, exe, plugin, etc. out there that lets you start and stop the server at specific times. not restart, i mean shut down and start the server entirely. im not sure if you can do that though commands in the cmd itself, or whether you need an exe with a script to start and stop the cmd entirely to be able to do that. 

just for context, im trying to start my server at 12am (noon) and end it at 3am every day. its realistically only a server for friends and a few other people in the grapevine, and there wont be anybody on from 3am-12am(noon), so i dont want the server running during that time. 

a friend and i just spent the last 4-5 hours trying to program a c++ script in visual studio to basically start the server one inital time, then once it meets that value it will trigger the rest of the commands (i.e. server.loadcfg, and then the shutdown warnings, then one final save and the server.stop. it will do the "quit" commands, which just stops the server but it immediately starts the server again after that. 

the problem we're having with the code though, which i will post below, is once it runs the initial command at 11:50 to start the server bootup, it will not trigger any other commands after that (i.e. the 11:58 command to server.loadcfg), or any others after that. on the contrary, all of the other commands will display in the cfg only if you dont do the 11:50 command to start the server first. it makes no sense.

so i guess this is kind of a double topic thread. 1), is there a better way or already existing way to do this, and 2), why isnt the coding working (for anyone that has C++ experience)

thanks in advance.

here is the code, and sorry in advance. there was no C++ option so i went with C#:

// Rust Server Times.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <windows.h>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <array>
#include <stdio.h>
#include <ctime>
#include <fstream>
#include <tchar.h>


#define WIN32_LEAN_AND_MEAN

using namespace std;

int main() {



    do
    {
        time_t now = time(0);
        tm* ltm = localtime(&now);
        int x = 0;



        if (ltm->tm_hour == 11 && ltm->tm_min == 50 && x == 0)
        {
            system("RUST_SERVER_START.bat");
        }

        if (ltm->tm_hour == 11 && ltm->tm_min == 58)
        {
            cout << "server.loadcfg";
        }

        if (ltm->tm_hour == 11 && ltm->tm_min == 50 && x == 1)
        {
            cout << "quit";
        }

        if (ltm->tm_hour == 2 && ltm->tm_min == 30)
        {
            cout << "say Server restarting in 30 minutes!";
        }

        if (ltm->tm_hour == 2 && ltm->tm_min == 45)
        {
            cout << "say Server restarting in 15 minutes!";
        }

        if (ltm->tm_hour == 2 && ltm->tm_min == 55)
        {
            cout << "say Server restarting in 5 minutes!";
        }

        if (ltm->tm_hour == 2 && ltm->tm_min == 59)
        {
            cout << "say Server is restarting in 1 minute!";
        }

        if (ltm->tm_hour == 2 && ltm->tm_min == 59 && ltm->tm_sec == 55)
        {
            cout << "save";
        }

        if (ltm->tm_hour == 3)
        {
            cout << "say Server is now shutting down until noon(12pm). Thanks for playing!";
            cout << "server.stop";
            x = 1;

        }
    }
    while (1);

}
There are plugins and well I doubt it works this way. Try Smooth Restarter
On Linux you would just set simple cron jobs for start/stop. I haven't been a Windows user for many years, but how about this:

https://en.wikipedia.org/wiki/Windows_Task_Scheduler

I don't fully understand your question about the in-server tasks, but whatever settings you want to mess around with after startup can be done with:

https://umod.org/plugins/timed-execute

... I'm surprised misticos didn't mention this one as it's one of his :)

Personally, I use this to announce my scheduled restarts, you get a nice big coloured in-your-face banner:

https://umod.org/plugins/gui-announcements
5b6ed4c9ac8e4.jpg misticos
There are plugins and well I doubt it works this way. Try Smooth Restarter
i have already tried smooth restarter, it just simply acts as a server restarter with a countdown timer. im trying to physically stop and start the server at designated times.

5c5339bb3cef3.png JimDeadlock
On Linux you would just set simple cron jobs for start/stop. I haven't been a Windows user for many years, but how about this:

https://en.wikipedia.org/wiki/Windows_Task_Scheduler

I don't fully understand your question about the in-server tasks, but whatever settings you want to mess around with after startup can be done with:

https://umod.org/plugins/timed-execute

... I'm surprised misticos didn't mention this one as it's one of his :)

Personally, I use this to announce my scheduled restarts, you get a nice big coloured in-your-face banner:

https://umod.org/plugins/gui-announcements
im currently on windows, i dont have any Linux experience, although that seems to be everyones go-to for servers for a number of reasons. i can try windows task scheduler to start the server at a certain time, then use the timed-execute commands to announce the server shutdown countdown globally, but i could probably do that through Rust Admin Client also, as they have the same features. gui-announcements looks highly configurable, i can try to see if that one will work too. 

my only issue with these solutions though, is that i dont want to have one main task achieved by doing 4 smaller tasks. if anyone has C++ experience id also like to possibly know why my code isnt working, or why it wont issue any other command after the first command issues into the console to boot up the server.
5e7075dba0fb6.png mike1000195
i have already tried smooth restarter, it just simply acts as a server restarter with a countdown timer. im trying to physically stop and start the server at designated times.

im currently on windows, i dont have any Linux experience, although that seems to be everyones go-to for servers for a number of reasons. i can try windows task scheduler to start the server at a certain time, then use the timed-execute commands to announce the server shutdown countdown globally, but i could probably do that through Rust Admin Client also, as they have the same features. gui-announcements looks highly configurable, i can try to see if that one will work too. 

my only issue with these solutions though, is that i dont want to have one main task achieved by doing 4 smaller tasks. if anyone has C++ experience id also like to possibly know why my code isnt working, or why it wont issue any other command after the first command issues into the console to boot up the server.

I'm using RSM Manager this software is made for rust only and I can tell you It's one of the best tool manager that i've ever used, 
You can set everyting inside of your server how you wanted to have it, 

TruxDeadnitro

I'm using RSM Manager this software is made for rust only and I can tell you It's one of the best tool manager that i've ever used, 
You can set everyting inside of your server how you wanted to have it, 

alright thanks man, ill check it out!
TruxDeadnitro

I'm using RSM Manager this software is made for rust only and I can tell you It's one of the best tool manager that i've ever used, 
You can set everyting inside of your server how you wanted to have it, 

alright so i looked into it, and i guess RSM is a paid program, which i really dont want to spend $30+ to be able to do what im looking for, just for a casual server between friends.. thank you for the suggestion, and although it may work for what i want it to do, i'll just leave the thread open until maybe somebody with some C++ experience might be able to see what im doing wrong in my coding..

You can use RCON tools to execute the command restart at the time that you wish for the server to restart, as long as your .bat file is setup correctly it will auto restart. Alternative is to use task scheduler on Windows.

 

RustAdmin rcon, Battlemetrics rcon tools etc all have scheduled commands options.

casualrussian

You can use RCON tools to execute the command restart at the time that you wish for the server to restart, as long as your .bat file is setup correctly it will auto restart. Alternative is to use task scheduler on Windows.

 

RustAdmin rcon, Battlemetrics rcon tools etc all have scheduled commands options.

i dont want an auto restarter. i want a server up-time scheduler. 

What is the problem with restarting it with commands, etc? You are doing it the same way in your application as I can see.

Merged post

Battle Metrics and etc have scheduled commands and that is exactly what your application does if i understand it correctly.
5b6ed4c9ac8e4.jpg misticos
What is the problem with restarting it with commands, etc? You are doing it the same way in your application as I can see.

Merged post

Battle Metrics and etc have scheduled commands and that is exactly what your application does if i understand it correctly.

yeah i could definitely get it to work with timed commands and windows scheduler, but im not specifically looking for a restarter.. im looking for a quick, simple, easy way to automate everything so that way my server shuts down at 3am so that way nobody else can log on between the hours of 3am and 12am. not a restart, more as a shutdown.

Quit and restart commands schedule a shutdown indeed tho, you have to manually start your server. You can use restart command or quit in any scheduler and then start it again back up with windows scheduler / ..
The thing is, if you're going to use win scheduler for the start, might as well use it for the stop as well.