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 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

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

  • 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
  • Avatar of admalledd admalledd Aug 04, 2014 at 04:14 UTC - 0 likes

    @cyclo666: Go

    Currently there is no "run script at startup" event or trigger available. Mind if I ask what your use-case is? Should not be hard to add a new event if there is a good use case, but I would rather not add events that I have to test every update if at all feasible another way.

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

    Is there any way to make a script run once on server startup?

    I'm not sure how @reboot would work with this plugin.

    Last edited Aug 04, 2014 by cyclo666
  • Avatar of admalledd admalledd Mar 30, 2014 at 19:50 UTC - 0 likes

    Heads up: due to mojang switching to UUIDs for player identification and such the EventEngine tab.sce is going to have to change a tad. I hope to be able to do a automatic conversion, but currently am not seeing a way to do so. The change will involve the "filters" part of the event scripting.

  • Avatar of admalledd admalledd Mar 11, 2014 at 17:51 UTC - 0 likes

    @mistermsk: Go

    Mind posting the tab.sce and event.sce file(s) and what your goal is? My automatic testing still shows its working, but I admit that the filtering is one that I don't test very well and you might have hit an edge case (or my docs need more explaining/examples)

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
2,907
Recent files

Authors