Timed Commands (Premium)
An in-depth guide on how to configure timed commands and some handy links to assist with the CRON timers.
Timed Commands Introduction
Welcome to our next premium feature on the list, Timed Commands. Through this part of the documentation we will be going through how to apply an automatic timer to the CMD groups for them to run periodically at a time frame of your choice, completely automatically.
Timed commands will play a huge part in relieving some of your manual duties as a server owner, not forgetting that it also allows you to run in game messages very frequently on screen, giving you the power to now advertise your communication platform (Discord and others) on screen for all of your users to see.
Timed commands can also be used for things like enabling and disabling PVE modes in game, trigger custom automatic events, rewarding your player base on a regular basis, the possibilities for you and your players are now endless in terms of what you can do.
It is a highly recommended that if you are unsure of what Command Groups are, that you please read through its documentation by clicking here before continuing.
Configuring Commands
Timed commands use the Command Groups (CMDs) we created earlier and adds an automatic schedule to them using whats called a CRON timer. Lets go through setting a Timed Command up.
Adding/Updating a Timed Command
Adding and updating a timed command uses the same / command as we have already added the group earlier when we covered command groupd, to start the process of adding a timer, we need to use the command /tc addupdate which will allow us 4 options;
- Gameserver - Select the gameserver where you want the Timed Command to be triggered
- Nickname - Give the Timed command a nickname so you can identify it
- cron - We will need to obtain a CRON expression, we will cover this later
- command-group - Please select one of your earlier created command groups.
By choosing these 4 options we can successfully create a Timed Command, please see the image below for a snap shot;
Listing our Timed Commands
Whenever we need to check, edit, rearrange or remove a Timed Command, it can be hard to remember which command we need to obtain, using the command /tc list the bot will show us all current Timed Commands which we have installed.
Please see the image below for a snapshot;
Triggering a Timed Command
After we install a timed command, ideally we need to test it, however, because it is set on a timer we cannot test it until that time comes. (Can you imagine if this was really the case for a command that only triggers every 12hrs). This is why we introduced the Timed Command Trigger, it allows you to perform a "Test Run" on your Timed command so that you can be sure that it all works OK. To do this we simply need to use the command /tc trigger, this will give you the chance to select a command group to trigger for your testing. Once you select it, the command will run as if the allotted time has elapsed. Please see the image below for reference;
Deleting a Timed Command
Should you no longer need a timed command because either its now redundant or you simply don't want it, all you need to do is use the command /tc delete This will remove the timer from the command group and will leave the group stored in your bot until you choose to delete that also, So for clarity, it just removes the automation.
Using the CRON Timer
Using Cron Expressions for Scheduled Tasks
Cron expressions are a way to define when a task or job should run. These expressions consist of five fields representing minutes, hours, day of the month, month, and day of the week. Here's a breakdown:
- Minute (0 - 59): The minute when the task should run.
- Hour (0 - 23): The hour when the task should run.
- Day of the Month (1 - 31): The day of the month when the task should run.
- Month (1 - 12): The month when the task should run.
- Day of the Week (0 - 6): The day of the week when the task should run (Sunday = 0).
Example:
Let's say you want to schedule a backup task to run every day at 2:30 AM.
- Minute:
30
- Hour:
2
- Day of the Month:
*
(every day) - Month:
*
(every month) - Day of the Week:
*
(every day of the week)
The cron expression would be: 30 2 * * *
Practical Steps:
1. Identify the Schedule:
Determine how often you want the task to run and at what specific time.
2. Use a UI or Application:
If you're using an application or service, there might be a graphical user interface (UI) where you can set up scheduled tasks. Look for a "Scheduled Tasks," "Cron Jobs," or similar section.
3. Input the Cron Expression:
In the scheduled tasks section, you may find a field asking for a cron expression. Enter the expression based on your desired schedule.
4. Examples:
-
Every 5 Minutes - */5 * * * *
- Every 30 Minutes - */30 * * * *
- Every Hour - 0 * * * *
- Every 12 Hours - 0 */12 * * *
- Every Day - 0 0 * * *
- Every Other Day - 0 0 */2 * *
- Every Friday - 0 0 * * 5
- Every Month - 0 0 1 * *
5. Save or Apply Changes:
After inputting the cron expression, save or apply the changes. The scheduled task should now adhere to the specified schedule.
Useful Links
A super useful link for a cron expression is https://crontab.guru/ - Please spend some time practicing and learning.