Search code examples
automationcrongarrys-mod

Starting something at a certian time and then stopping it


I run a Garry's mod server and I want to stop my server at 7AM then start it again. To safely close the server it requires me to type quit in the server console. How could I make a script that rules quit in the console then starts my start.sh file after that is done? I was looking at crontabs but they are confusing to me.


Solution

  • I'm not familiar with Garry's mod servers, but in general you can do the following in a cron file:

    0 7 * * * quit && /path/to/start.sh
    

    the first bit ensures that the command is run at 7AM of machine's time every day. You can use crontab guru as a simple UI that shows what the numbers and * mean on cron scheduling.

    I've assumed that quit closes the piece of code running on the machine, and doesn't restart or shutdown it down.

    Also make sure to use absolute paths when running scripts from cron files.