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.
Lamentably my java kwonledge is limited, I have JDK and eclipse installed but I'm not a programmer. The next year I will learn the java lenguage, it is interesant for me :), maybe I could collaborate with other developpers.
I only can offer server suggestions to avoid lag, my suggestions are based in 2 years of experience, maybe it could be usseful for some people.
- Assign the -Xms and -Xmx to a nearby value. The -Xms is the memory that you assign to waste before a ram cleanup (garbage recolection) is made. (Ex: java -jar -Xms8G -Xmx9G yourjavaexec.jar)
- Disable swap. I've discovered that sometimes java is moved to the swap and it lags so much. The HDD is slow and when java tries to make a garbage collection that proccess is slowed by the hdd and it causes lag or crashes your server with an outofmemory error because java can't remove garbage so fast that it needs.
- If you are running more than one servers (Example a Hungergames) you can use "taskset -c <core/cores>" to issolate server processors, you could force only a core without affecting the other server performance. (Ex: taskset -c 0,1,2 java -jar -Xms8G -Xmx9G yourjavaexec.jar - This will force java to use only 3 proccesors of 4)
- Finally you need to make sure that your system isn't out of ram. The system is very important, if your OS is running without sufficient ram it will slow all your server and java doesn't give memory back.
Maybe it could be a good idea to post that suggestions on the forum but I'm not english and maybe some expressions aren't correct. Internet is a good way to learn english :)
................................................ Lamentably I tried to automatize a world restart every week with this plugin, but multiverse cant delete default worlds... (I like to reset the end). I suppose that I can force an "rm -rf pvp_the_end" one minute before my server restart.
@Shelmak
Yes, program output is buffered. Normally its best to move things that would fill/jam the buffer(s) to a .sh script and have it redirect the output to a usable log file instead of trying to pass it back to the SCC/SCE script.
Feel free to link your usefull scripts, or submit a pull request to the "SimpleCronClone/examples" directory and I will make sure to add them somewhere. (maybe it is time I make a new repo for examples...)
yea, plugin passes all my critical tests for 1.6.1 spigot or craftbukkit, but for some reason is still inaccurate in the tick timer for the "hourChange" and friend events of SCE. I hope to have time to look at it in more detail some time this week, I need a friend who knows more about JVM debugging than me to lend me a hand (or I may just give up and put a disclaimer saying that the SCE time events are "best effort"...)
Hi, I have a suggestion... You could create a subcategory called "Useful scripts". I could post some scc/sh scripts that I'm actually using on my server.
An issue of this plugin is that tar (tar, linux packager) is blocked if verbose mode is activied. It seems that when "tar -cvf ..." is executed backups are blocked. The solution is disable the vervose (-v) parammeter.
It works whith this: "tar -cf ..." This issue is not important, I suppose that your plugin buffers the text ouput of the script and when it reachs the limit it doesn't respond. The plugin still working normally but the executed task still blocked forever, until a server restart isn't executed or you stop/kill the script.
Plugin works in 1.6, I tried it on a test server with no errors.
rough testing on 1.6.1 spigot and CraftBukkit are looking good. SCE and SCC engines are running fine as far as I can tell (ish, more later).
I am stuck away from my computers right now visiting family on vacation, so I cant run my extensive tests, only update my server to the latest dev builds and hope for the best. so far nothing is worryingly wrong, however it may seem that the SCE engine's time events (midday,midnight,ect ect...) are a couple ticks off (10-50?). I dont have the tools here to look in detail, so my apologies about that. I will look when I am back home, about a 10 ish days.
so, except for a (very small) inacuracy in the SCE timing engine, SimpleCronClone seems to be handling the update fine. As always post comments if things are not working out and i will get back as quickly as possible. Note that for the next week or two is kinda hectic for me so I might be slower than normal to respond (read: may take a day or two)
@o0Julia0o
sorry that I can't be of more help then. I have no windows computers anymore to test programs on. If you need anything else then let me know!
@admalledd
hmm.. o.k. thank you. I have no Unix-based OS.
thx
julia :)
@Shelmak
Indeed you can put your messages into a temp file and use "execwait cat /tmp/tempfileblah", just finished playing around with it a bit: first off, you can use chat codes (ish, depends on your plugin) inside the tempfile itself. Second off, it does not like new lines (or more of: minecraft chat does not let you send multiple lines without multiple commands or lots of painstaking formatting), it just ignores them or replaces them with a space (depending on language settings I think).
My test was a line file with this line:
"This is a remote file test, §cThis is a color test"
the test.scc script was simply "execwait cat /tmp/scctest.txt" then a "do say $?", returning a correctly formatted message in-game ("This is a remote file test, This is a color test") with the color part being red thanks to formatting.
as for the not executing scripts/not finishing a script if an error is detected, well thats sort of the point by default(unless I misunderstand what you mean). if something went wrong that means that the plugin has no idea how to recover from whatever got messed up. Hence the point of testing scripts and those commands, makes it easy to see if things are working. If you think it is error'ing out incorrectly (eg, you think for some reason it should work but it is not) post what the error is (from the server.log) as well as the script itself.
(Don't worry about your english, its better than most people I work with :D. I actually have a hard time testing my plugin for multiple languages and such, so if it ever barfs over something like a weird symbol or such, please let me know so I can track it down.)
Ouch, ok... but then your plugin doesn't executes a scc script if errors were detected. I like to parse variables to the server..., I suppose that I can save variables to a txt file and take them with a "cat file.txt"
My intention is to provide server info (Such used Gb for backups) Sorry for my english jajaja.
And yes, I edit my messages very much
@Shelmak
you edited as I was replying eek! (I live by my email when im working on things, so if im near a computer I always try to reply quickly.)
looking at your backup.scc, ExecWait doesn't work that way sadly, it is meant to exec() one program, with a few arguments, it is not interpreted at all by any shell. it is executed directly by the JVM and the host OS. if you want to chain those together you would have to put those snippets into a shell/bash script. Basically no | or backtick or $() expansion in SCC or SCE scripts, that is very complicated to get right so I prefer to leave that to the better tools to get right (shells/interpreters ect)
Ohh, wow, you are very fast XD. Thanks, I will test it :)
@Shelmak
the command is "/simplecronclone exec $script.scc" (it can only exec SCC scripts, so no EventEngine scripts sadly). Quite a while ago there was some conflict with /scc and some other plugin, it was decided that it would be easier to just use the full name. This is mostly due to the fact that the commands are there more for testing and admin use, not day-to-day use as such.
"/simplecronclone exec" requires the permissions node "simplecronclone.exec"
If you have any other issues or need some help let me know :D
Umm.. I have a suggestion. I like to test scripts directly on my server, can you add a command to force execution of an scc script?
Example: /scc exec backup.scc
I like to make a server backup every day but it seems that it doesn't work. Backupdiario.sh works if i execute them with ./backupdiario.sh
tab.scc
backup script scc (backupdiario.scc)
Backup script (backupdiario.sh, located on script forder)
<<code sh>>
@o0Julia0o
Sadly that is outside the scope of what SCC or SCE is meant to do on its own, at that point I would recommend a custom program that hooks into JSONapi or some such and is fired whenever the DAYTIME event occurs, and then have the custom program query JSONapi if PLAYER is online or not.
Are you running on a unix based OS/have a python interpreter or some such installed? I can write a script to hook into JSONapi fairly easily, I have something like what you are asking for already on my server and I could adapt it to yours if I know what OS/interpreters you had on the server.
how can i make this?: -mesage y on DAYTIME y & if PLAYER x is online
thx
Julia :)
@Shelmak
So long as my server is running I will maintain this plugin, and even after that so long as people donate every once in a while for my time. So no worries there. Good to hear that the script worked and all that!
Ok it works. I had problems executing the phyton script on ssh but now are solved. It works, when there aren't players script isnt executed and when there are players on that list script is executed.
Thanks for your help. I hope that this plugin dont die.
@Shelmak
ticket opened for the idea of adding line support to "do $?" or something along those lines (3 ideas to start, might be others...)
I think it will be likely I will instead of adding that feature will add a couple examples about using other command-injection plugins along with SimpleCronClone. However this depends on my sanity check for stuff and all that. If you wish for it to be added and you might have something to add to which solution (or even a whole different one!) please feel free to comment on the ticket on github.
Its ok, i will test the script tomorrow. I will inform you when i've tested it on my test server.
However it could be a good idea to make a second command "do" with line support if you have free time. Not for me, of course, you gave me the solution but maybe it could be a good feature. Thanks.
@Shelmak
well, it was actually simpler to set up JSONapi over ssh than i thought for my test server :D
So, two parts of this: first is the python code that will take a file listing all the users to promote (you will have to edit this with respect to your servers username/password stuff) and then also download and put the python JSONapi SDK on your pythonpath somewhere (same folder as this code can work just fine, name it JSONapi.py)
in your script that you currently call, replace the loop with calling `python promote.py /path/to/premiums.txt` or whatever. That *should* do what you are asking about.
also: aww shucks! thanks! I actually only maintain the plugin/add new features/support/help out, the original plugin was written quite a while ago by bobby_bonsai, but he got too busy so i took over for the most part.
anywho, that should be it i think. sadly i now have to run for an hour or so, ill check back later ok?
@admalledd
Thank you admalledd, but there is no hurry. You had a good idea making this plugin, it is very usseful and simple and thanks to you i can use .sh scripts to manage my server :)
Example: I will shedule a map restart on my hungergames server every day using your plugin by sheduling a 4 o'clock halt, deleting the map and restarting the server. Also it is very usseful to renderize a http map when there aren't players on the server. Its a great plugin. Good work.
Thanks for your help.