SimpleCronClone

There are two parts to SimpleCronClone: scheduled scripts based on a cron-like syntax, and scripts that are called when certain events occur.

SimpleCronClone

This part of the plugin mimics the behavior of cron (for Windows-Users: Planned Tasks) and allows you to schedule scripts and commands for execution. It uses the awesome cron4j scheduler written by Carlo Pelliccia and it's own very, very, very, very, very basic scripting language.

How does it work? Well, the file plugins/SimpleCronClone/tab.scc is used as crontab-file, but instead of whole commands, it only takes the names of scripts. The tab file is parsed and scheduled, and when according the the cron part, the script is ran.

The CronClone part is to help with automated tasks that every server needs help with. For example:

  • sending a message to the console every set amount of time.
  • running a series of scripts that are dependent on the server running (eg, backups, off-site backups and more)
  • running a series of in-game commands every so often (clearing logs, resetting arenas and much more, depending on your other plugins)
  • query OS programs for status or information and use that information inside of the SCC script

EventEngine

New in v1.0, the EventEngine is a extension to the normal SimpleCronClone that calls event scripts (ending in .sce) when certain events occur.

The idea of this is that now by adding scripts to plugins/SimpleCronClone/tab.sce you will be able to do certain stats gathering or any other kind of thing based on events that players themselves cause. An example is lets say you have an adventure world, you can set a script to be run saying "do say hey player $1 is now playing in $2 adventure map, go join!" when a world is no longer empty, and when the world is empty again have a script revert it to normal. This is just one of many things that could be done with the EventEngine. See the events page for what events can be scheduled and how.

Script Format

See here

Tab Format

See here

Warning about security

One word of warning: Whatever you'll execute, it will have the same rights as the user from which the server is run. So be careful. Also keep in mind the execution-directory of the script is the server-directory for executables, not the plugin-directory.

Source and issue tracker

source code
bug tracker

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of uvbeenzaned uvbeenzaned Jan 31, 2015 at 00:06 UTC - 0 likes

    @admalledd: Go

    Thanks.

    BFAK:14612,4800d22fc9e3d6603d0412ae23e59102fbd0b143eada81d248519804e3937535

  • Avatar of admalledd admalledd Jan 30, 2015 at 23:14 UTC - 1 like

    @uvbeenzaned: Go

    There are no real plans to add filtering like that for the CronEngine. Either they run or the don't. The solution is to in your backup script add logic that would query the server somehow to know if there are players online or not. Something like the bukkit JSONAPI (eg the method "players.online.count" sounds like what you want/need) is probably the way to go. Again SCC/SCE is meant for very rudimentary scheduling and any fancy filtering past that should be done by the program executed in the script.

    For the most part I would personally recommend that unless you have very specifically good reasons you should *always* be running your backups. Players online or not.

    Programmer looking for work, prefer python and java in a *NIX environment. PM for details or email [email protected] (email is faster)

  • Avatar of uvbeenzaned uvbeenzaned Jan 30, 2015 at 22:26 UTC - 0 likes

    Hi admalledd! I love your plugin, it has been the only answer to my custom backup problem. I have, however, another issue that needs addressing. How do you get the SCC script that runs every 30 mins to run only when the server has someone on it?:

    do broadcast Starting automatic server backup... do save-all do save-off execwait /home/User/Server/manual-backup do save-on do save-all do broadcast Finished backup!

  • Avatar of admalledd admalledd Dec 22, 2014 at 07:13 UTC - 0 likes

    Note for spigot 1.8: Tested working for the CronEngine perfectly. EventEngine is not UUID-aware and sometimes barfs if users change name or such and you are trying to filter users. (AKA: Version 1.2 still works just fine for everything I said it would)

    For the future though, due to lack of other peoples interest I will only be supporting features I myself use. Contract work to update/support extended features beyond that is fine reach me via github, email or reddit. And due to the uncertanty of future minecraft servers I am not even 50% sure where this plugin will be in the future with respect to Sponge or whatever comes next, thus where my support of features I use comes in: I expect to basically always still want CronEngine and some of the basics of EventEngine (user logged in, teleported worlds, server (Not)Empty) but more than that I don't really know. Too much uncertainty.

  • Avatar of admalledd admalledd Aug 04, 2014 at 07:03 UTC - 0 likes

    @cyclo666: Go

    Well good news then for you, I should have free time to work on SCC sometime this week and the "at server start" event should be easy to add, although I would like a users perspective on how to handle reloading the whole plugin tree or even just restarting SCC:

    https://github.com/RobertZenz/org.bonsaimind.bukkitplugins/issues/36#issuecomment-51023929

  • Avatar of cyclo666 cyclo666 Aug 04, 2014 at 06:14 UTC - 0 likes

    @admalledd: Go

    You're right. I could just use cron to schedule a restart at a specific time. I have several .scc scripts where cron is sufficient, I just wanted it to be after a certain amount of uptime and cron doesn't give me that.

    It's not really that crucial though, and I could just fallback to a cronjob if I can't figure it out another way.

    RT does listen to the console.

    Last edited Aug 04, 2014 by cyclo666
  • Avatar of admalledd admalledd Aug 04, 2014 at 06:02 UTC - 0 likes

    @cyclo666: Go

    Right, and to handle restarting instead of saying "after 24 hours uptime do $blah" think instead along the lines of "every day/week at such hour, do $blah" where here $blah is " do .reschedulerestart 10m". An example for running a "restart.scc" every day at 5 AM (server time):

    #in "tab.scc"
      0    5    *    *    *     restart.scc
    

    Also, does RT hook into the console so that typing ".$command" is listened to? SCC sends commands to the minecraft OP command handler via "server.dispatchCommand(server.getConsoleSender(), command);" If RT hooks in a different way, make sure to send its restart command in a way it understands as if you were OP inside minecraft. Otherwise you will have to use some form of external program to tell RT to restart (Like I have my "restart.sh" that hooks into GNU screen for me)

  • Avatar of cyclo666 cyclo666 Aug 04, 2014 at 05:35 UTC - 0 likes

    @admalledd: Go

    Well, if the server does ever crash, which is extremely rare, I have a wrapper in place that detects when the server is not responding and forces a restart. \

    The reason why I want it to restart after 24 hours of uptime is to keep everything 'fresh'. The server as far as I can tell is just fine, no lag at all. But eventually, after the server has been up for days on end players will start complaining about block lag etc etc, and sometimes a quick restart does fix that.

    The wrapper i mentioned is remotetoolkit. That itself has an option to restart every x amount of time but it doesn't allow you to broadcast a message before the restart countdown begins.

    Last edited Aug 04, 2014 by cyclo666
  • Avatar of admalledd admalledd Aug 04, 2014 at 05:17 UTC - 0 likes

    @cyclo666: Go

    Ah, two things then: One, it is generally a bad idea to have the server restart managed by the server itself (via plugin basically) this leads to issues such as what if the server crashes how would it manage that?

    The other is that of course for a while I ignored that and ran some of my smaller servers using SCC to restart, here is the breakdown of that old code:

    • restart.sh: shell script to talk to GNU screen for me and inject the restart commands.
    • restart.scc: SCC script that executes the restart, nothing interesting. Biggest thing to note is use "exec" so that the restarter spawns in a background process and java won't wait for that new process to end before shutting down.
    • tab.scc: example CronTab file, mostly to show stuff i guess? Included for completeness sake.

    Now a note: if you are going to ever do anything like a "sleep" for more than a few minutes it would be better to just schedule a script for that time itself (or "exec" a new background process and handle all the timing there). Thus you just set up your restart script to run every day at say 5AM. Unless you have reasons you always want it as a "24 hours from server startup"?

    Either way, opened a few issues for me to look at sometime this week that might interest you (but basically until they are done what you ask of "startup script" is not possible): SCC 1.3 tracker

  • Avatar of cyclo666 cyclo666 Aug 04, 2014 at 04:41 UTC - 0 likes

    @admalledd: Go

    It's just a very simple restart script. It would execute after the server has started, sleep for 24 hours then run.

    execwait sleep 24h
    do bc Server has been up for 24 hours. Scheduling a restart to fix any potential lag issues.
    do .reschedulerestart 10m

    Last edited Aug 04, 2014 by cyclo666

Facts

Date created
Feb 06, 2013
Category
Last update
Aug 10, 2013
Development stage
Release
License
GNU General Public License version 3 (GPLv3)
Curse link
SimpleCronClone
Downloads
3,247
Recent files

Authors