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

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

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

  • Avatar of mistermsk mistermsk Mar 11, 2014 at 15:36 UTC - 0 likes

    Running Bukkit 1.7.2-R0.4. I tried the lastest release. The triggers seem to work fine. However, when teleporting from world to world the filters do not seem to work. If I have worlds a, b, and c on my server. I filtered out world a. I still see the message from teleporting from world b to world c. I did the - a and also tried - - a to check. Any suggestions?

  • Avatar of admalledd admalledd Jan 25, 2014 at 07:17 UTC - 0 likes

    @Scorpion_vn: Go

    if its two (or more) different event engine scripts (.sce), then you have to copy/paste and have a copy of the same filter configs, EG:

    playerJoin:
    #for both player Scorpion and admalledd
        - file: 'event_file_onplayerjoin_one.sce'
          filters:
              players:
                  - Scorpion
                  - admalledd
              worlds:
    #for only player Scorpion
        - file: 'event_file_onplayerjoin_two.sce'
          filters:
              players:
                  - Scorpion
              worlds:
    #for all players
        - file: 'onplayerjoin.sce'
          filters:
              players:
              worlds:
    

    Although at that point would it not be better to join the two .sce files into one?

    I am away from my test machine so I can't be 100% sure this is how it works, but should be about right...

    Although I have a feeling I might be miss-understanding exactly what you were asking, if thats the case please let me know!

  • Avatar of Scorpion_vn Scorpion_vn Jan 24, 2014 at 17:24 UTC - 0 likes

    Hi, respect for your hard work. I played around a bit and for me it seems like I cant make event fire two different files - one unconditional and one with filters. Can you give us working example how to call two different files on playerJoin Event.

    The examples did not say "famous person Scorpion joined" for example.

    Best regards

  • Avatar of admalledd admalledd Dec 02, 2013 at 08:53 UTC - 0 likes

    Just tested SCC with both spigot-1148 and craftbukkit-2924 (early 1.7.2 builds), here is the news from the trenches:

    Seems that things work just fine, passing my test suite just the same as it was before. The event "playerFirstJoin" seems to be working reliably now, but not going to close its relevant issue until I can reproduce or explain why it was 10 seconds late once. (most likely my overloaded computer, but better to be safe...)

    EDIT: I should mention this test was for my own group of servers, so not my normal regression testing that takes about 5-6 hours against a pile of other plugins that might muck with the task scheduler or changes to the execution environment.

    TL;DR: plugin still works fine, but will report again in about a week with much more thorough testing (studying for finals so cant put more than 2 hours into this right now).

    As always if there are any issues open a ticket on github or post a comment here and I will reply as soon as I can.

    Last edited Dec 02, 2013 by admalledd
  • Avatar of admalledd admalledd Oct 21, 2013 at 19:10 UTC - 0 likes

    @Tritek: Go

    By default, and staying within the SCC/SCE engine: no, there is no included "sleep" command. however there are two other ways to do this if you so wish:

    if you are on linux or have the relevant windows server command "execWait" a external program that can wait/sleep for you. EG:

    #example for linux, see below for windows help (no mac information known, let me know if thats desired and ill look it up)
    do say restart in 10 seconds!
    execWait sleep 10
    #this is assuming that you have another plugin or server manager listening for the command "/restart", it is not part of SimpleCronClone.
    do restart
    

    for windows you need a different command in "execwait", see here for some ideas (different versions of windows use different commands...)

    The other option (that I personally use for my server) is to have multiple .scc files in the tab.scc scheduled one after another:

    # +----------------> Minute
    # |   +--------------> Hour
    # |   |  +------------> Day of month
    # |   |  | +----------> Month
    # |   |  | | +--------> Day of week
    # |   |  | |  |  +--> Script/File
    # |   |  | |  |  | 
    #warn of back up 15 minutes before it occurs:
      45 4 * * * warnrestart15.scc
    #warn of back up 10 minutes before it occurs:
      50 4 * * * warnrestart10.scc
    #warn of back up 5 minutes before it occurs:
      55 4 * * * warnrestart5.scc
    #warn of back up 1 minute before it occurs:
      59 4 * * * warnrestart1.scc
    #do restart:
      0 5 * * * restart.scc
    

    for how to do it by seconds and such refer to http://en.wikipedia.org/wiki/Cron#Format (basically num-num%s range)

    Because you want only a few seconds I would recommend using "execWait" because that is the simplest.

  • Avatar of Tritek Tritek Oct 21, 2013 at 18:19 UTC - 0 likes

    Hello. Is there a possible to do command:

    command "say Restart za 10 sekund"

    wait 10 seconds and

    command "/restart"

  • Avatar of admalledd admalledd Sep 27, 2013 at 08:43 UTC - 0 likes

    @PYROBITCH123: Go

    ok, so a few things to start off with:

    1. SCC doesn't understand shell environment variables (eg your $HOME). The server is literally trying to fork()/exec() "/$HOME/Desktop/bukkit/plugins/SimpleCronClone/save_world.sh" which does not exist (the path expanded one I assume does...)
    2. "simplecronclone exec" executes a .scc script, not shell scripts or anything else (it actually runs it through as if it was a timed script from within the cron engine, so no event parameters/arguments are passed)

    thus, modify your backup.scc to be (eg for $HOME==/home/admalledd on my system)

    "exec /home/admalledd/Desktop/bukkit/plugins/SimpleCronClone/save_world.sh"

    and your command to manually execute would also be:

    "simplecronclone exec backup"

    now to the *why* of no environment variables: In general doing sub-processes properly in a cross platform way is... complicated to say the least, so the basic stance is "have a path relative script in your server directory, have your native shell now handle env vars". If you have any ideas on how to approach subprocesses better that fork in the background that are a bit better than the normal java API way then let me know and I will take a look into adding support that way. (this includes parsing the different platforms env markings eg %PATH% vs $PATH ect ect...)

    editing the script format page to include the note about no environment variables. Sorry for missing documenting that.

    Anything else that I can help you with? although note its a bit late at night here now, so I will have to answer any more questions in the morning... sorry again for taking so long to reply, CurseForge dislikes sending me alerts in a timely manner...

  • Avatar of PYROBITCH123 PYROBITCH123 Sep 27, 2013 at 06:42 UTC - 0 likes

    I am attempting to execute an external shellscript with SimpleCronClone. In each variation of how I try to run it, either from the console directly or by using a .scc script, it is unable to see the shellscript ("Log" below). In certain cases it fails because it cannot find "save_world.sh.scc" which leads me to believe that it is trying to execute it as if it were a .scc script. I don't know why that would be happening, but I'm sure it's user error on my part. Any help here would be hot. ;)

    TRYING TO EXECUTE THE SHELLSCRIPT DIRECTLY

    >simplecronclone exec /$HOME/Desktop/bukkit/plugins/SimpleCronClone/save_world.sh

    23:12:26 [INFO] [SimpleCronClone] Executing: plugins/SimpleCronClone/$HOME/Desktop/bukkit/plugins/SimpleCronClone/save_world.sh.scc 23:12:26 [WARNING] [SimpleCronClone] Could not find script: "plugins/SimpleCronClone/$HOME/Desktop/bukkit/plugins/SimpleCronClone/save_world.sh.scc" 23:12:26 [INFO] SimpleCronClone: Error while executing "plugins/SimpleCronClone$HOME/Desktop/bukkit/plugins/SimpleCronClone/save_world.sh.scc".

    >simplecronclone exec /save_world.sh

    23:13:12 [INFO] [SimpleCronClone] Executing: plugins/SimpleCronClone/save_world.sh.scc 23:13:12 [WARNING] [SimpleCronClone] Could not find script: "plugins/SimpleCronClone/save_world.sh.scc" 23:13:12 [INFO] SimpleCronClone: Error while executing "plugins/SimpleCronClonesave_world.sh.scc".

    USING A .SCC SCRIPT TO EXECUTE THE SHELLSCRIPT

    >simplecronclone exec backup.scc

    23:17:12 [INFO] [SimpleCronClone] Executing: plugins/SimpleCronClone/backup.scc 23:17:12 [WARNING] [SimpleCronClone] Failed to execute script "plugins/SimpleCronClone/backup.scc" at "/$HOME/Desktop/bukkit/plugins/SimpleCronClone/save_world.sh" Cannot run program "/$HOME/Desktop/bukkit/plugins/SimpleCronClone/save_world.sh": error=2, No such file or directory 23:17:12 [INFO] SimpleCronClone: Error while executing "plugins/SimpleCronClone/backup.scc".

    Contents of backup.scc:

    exec /$HOME/Desktop/bukkit/plugins/SimpleCronClone/save_world.sh

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,694
Recent files

Authors