arkmanager / ark-server-tools

Set of server tools used to manage ARK: Survival Evolved servers on Linux
MIT License
681 stars 144 forks source link

Quick exemple for installing a cronjob #543

Closed arkfrance closed 8 years ago

arkfrance commented 8 years ago

Hey, i wanted to be sure of how to write the cronjob properly

arkmanager install-cronjob useconfig centpve rconcmd "serverchat tapez www.admin dans le tchat pour appeler un admin" --minute=5

is that correct ?

klightspeed commented 8 years ago
arkmanager useconfig centpve install-cronjob rconcmd --arg="serverchat tapez www.admin dans le tchat pour appeler un admin" --minute=5
arkfrance commented 8 years ago

that will add a cron in the crontab -e ? right

klightspeed commented 8 years ago

Found a bug in it - it should work now.

Provided the user is permitted to have a crontab, the following command:

/usr/local/bin/arkmanager useconfig centpve install-cronjob rconcmd --arg="serverchat tapez www.admin dans le tchat pour appeler un admin" --minute=5

should add the following cron job to the user's crontab:

5 * * * * /usr/local/bin/arkmanager --cronjob rconcmd @centpve "serverchat tapez www.admin dans le tchat pour appeler un admin"

The --cronjob option just tells the program that it's in a cron job.

arkfrance commented 8 years ago

steam@ns3013274:/root$ /usr/local/bin/arkmanager useconfig centpve install-cronjob rconcmd --arg="serverchat tapez www.admin dans le tchat pour appeler un admin" --minute=5 Running command 'install-cronjob' for instance 'centpve' no crontab for steam sed: -e expression n°1, caractère 16: commande inconnue: `u' steam@ns3013274:/root$ ^C steam@ns3013274:/root$ su root Mot de passe : root@ns3013274:~# /usr/local/bin/arkmanager useconfig centpve install-cronjob rconcmd --arg="serverchat tapez www.admin dans le tchat pour appeler un admin" --minute=5

Running command 'install-cronjob' for instance 'centpve' sed: -e expression n°1, caractère 16: commande inconnue: `u' root@ns3013274:~#

i've tried with root and steam user, that's what i've get

klightspeed commented 8 years ago

It should be fixed now with 421c2c4

arkfrance commented 8 years ago

seems to work once but not every 5 minutes

5 * * * * /usr/local/bin/arkmanager --cronjob rconcmd @centpve --args serverchat\ tapez\ www.admin\ dans\ le\ tchat\ pour\ appeler\ un\ admin -- >/dev/null 2>&1

ingame tchat

[12:05:07] tapez www.admin dans le tchat pour appeler un admin [12:09:37] Nico (Nico): bonjour [12:09:47] 504ERROR (Jean-Claude Van Damne): Salut [12:09:57] Nico (Nico): les plantes specimen X faut les mettre sur quel target ici pour pas etre embeter? [12:20:17] [FR] Ymmortel (Tsujiko): 30% apprivoiser T.T [12:20:27] 504ERROR (Jean-Claude Van Damne): quand ta une base entre la plage et l'eau y'a pas un truc estetique pour irrigu? le tout? [12:20:37] 504ERROR (Jean-Claude Van Damne): sans mettre des tuyau a travers tout [12:21:37] [FR] Ymmortel (Tsujiko): dans 2 semaine deux nouveau dino :3

klightspeed commented 8 years ago

If you want it to run every 5 minutes, then try --minute='*/5'

arkfrance commented 8 years ago

/5 * * * \ /usr/local/bin/arkmanager --cronjob rconcmd @centpve --args serverchat\ tapez\ www.admin\ dans\ le\ tchat\ pour\ appeler\ un\ admin -- >/dev/null 2>&1

i'm waiting to check the next 5 min

klightspeed commented 8 years ago

That --args tells arkmanager to take everything after it up to the -- as arguments to the command.

arkfrance commented 8 years ago

ok it's working maybe you should add the --minute='*/5' when someone use it for every x minutes

arkfrance commented 8 years ago

What sould i write for every x hours ?

arkfrance commented 8 years ago

it seems that everytime i add one it removes the previous one

klightspeed commented 8 years ago

At the moment, install-cronjob only supports one cronjob per instance. Perhaps we can add a --job=n argument that allows one to specify a job name or number.

To specify every n hours, use --hour='*/n'. If --minute=x is not specified, it defaults to 0.

I have pushed a change to the documentation to make this clearer.

arkfrance commented 8 years ago

i've mad my own one, maybe it will help someone :)

/2 * * * * /usr/local/bin/arkmanager useconfig val update --warn 30 5 * * * /usr/local/bin/arkmanager useconfig val backup /2 * * * * /usr/local/bin/arkmanager useconfig pvp update --warn 30 6 * * * /usr/local/bin/arkmanager useconfig pvp backup /2 * * * * /usr/local/bin/arkmanager useconfig pve update --warn 30 4 * * * /usr/local/bin/arkmanager useconfig pve backup /25 * * * * /usr/local/bin/arkmanager useconfig pvp update --update-mods --warn /25 * * * * /usr/local/bin/arkmanager useconfig pve update --update-mods --warn /25 * * * * /usr/local/bin/arkmanager useconfig val update --update-mods --warn /30 * * * * /usr/local/bin/arkmanager useconfig pve rconcmd "serverchat Merci de verifier les informations dans le pilier des regles disponible dans vos engrams avant de contacter un admin" /20 * * * * /usr/local/bin/arkmanager useconfig pve rconcmd "serverchat Tapez www.admin dans le tchat pour appeler un admin" /59 * * * * /usr/local/bin/arkmanager useconfig pve rconcmd "serverchat Dans le but d'aider au financement du serveur (85euro), une boutique est disponible sur notre site avec en vente des dinos, kibbles, compos et meme $ /30 * * * * /usr/local/bin/arkmanager useconfig pvp rconcmd "serverchat Merci de verifier les informations dans le pilier des regles disponible dans vos engrams avant de contacter un admin" /20 * * * * /usr/local/bin/arkmanager useconfig pvp rconcmd "serverchat Tapez www.admin dans le tchat pour appeler un admin" /59 * * * * /usr/local/bin/arkmanager useconfig pvp rconcmd "serverchat Dans le but d'aider au financement du serveur (85euro), une boutique est disponible sur notre site avec en vente des dinos !" /30 * * * * /usr/local/bin/arkmanager useconfig val rconcmd "serverchat Merci de verifier les informations dans le pilier des regles disponible dans vos engrams avant de contacter un admin" /20 * * * * /usr/local/bin/arkmanager useconfig val rconcmd "serverchat Tapez www.admin dans le tchat pour appeler un admin" /59 * * * \ /usr/local/bin/arkmanager useconfig val rconcmd "serverchat Dans le but d'aider au financement du serveur (85euro), une boutique est disponible sur notre site avec en vente des dinos, kibbles, compos et meme des golds !"

klightspeed commented 8 years ago

minute values of */n where n is not a factor of 60 will not work the way you expect. */59 will trigger on both the first and last minutes of the hour.

See the http://wikipedia.org/wiki/Cron

Note that frequencies in general cannot be expressed; only step values which evenly divide their range express accurate frequencies (for minutes and seconds, that's /2, /3, /4, /5, /6, /10, /12, /15, /20 and /30 because 60 is evenly divisible by those numbers; for hours, that's /2, /3/, /4, /6, /8 and /12); all other possible "steps" and all other fields yield inconsistent "short" periods at the end of the time-unit before it "resets" to the next minute, second, or day; for example, entering */5 for the day field sometimes executes after 1, 2, or 3 days, depending on the month and leap year; this is because cron is stateless (it does not remember the time of the last execution nor count the difference between it and now, required for accurate frequency counting-- instead, cron is a mere pattern-matcher).

arkfrance commented 8 years ago

yeah the messages are not working, they are all at the same time

[13:59:03] Dans le but d'aider au financement du serveur (85euro), une boutique est disponible sur notre site avec en vente des dinos, kibbles, compos et meme des golds ! [14:00:03] Tapez www.admin dans le tchat pour appeler un admin [14:00:03] Dans le but d'aider au financement du serveur (85euro), une boutique est disponible sur notre site avec en vente des dinos, kibbles, compos et meme des golds ! [14:00:03] Merci de verifier les informations dans le pilier des regles disponible dans vos engrams avant de contacter un admin

arkfrance commented 8 years ago

that will work

/30 * * * * /usr/local/bin/arkmanager useconfig centpve rconcmd "serverchat Merci de verifier les informations dans le pilier des regles disponible dans vos engrams avant de contacter un admin" /20 * * * * /usr/local/bin/arkmanager useconfig centpve rconcmd "serverchat Tapez www.admin dans le tchat pour appeler un admin" /50 * * * * /usr/local/bin/arkmanager useconfig centpve rconcmd "serverchat Dans le but d'aider au financement du serveur (85euro), une boutique est disponible sur notre site avec en vente des dinos, kibbles, compos et meme $ /30 * * * * /usr/local/bin/arkmanager useconfig centpvp rconcmd "serverchat Merci de verifier les informations dans le pilier des regles disponible dans vos engrams avant de contacter un admin" /20 * * * * /usr/local/bin/arkmanager useconfig centpvp rconcmd "serverchat Tapez www.admin dans le tchat pour appeler un admin" /50 * * * * /usr/local/bin/arkmanager useconfig centpvp rconcmd "serverchat Dans le but d'aider au financement du serveur (85euro), une boutique est disponible sur notre site avec en vente des dinos !"