loki1991 Posted October 7, 2012 Posted October 7, 2012 (edited) Heyho,I stopped my work on any ragnarok server. So this is a small farewell gift.This small scripts can be used as Cronjob (http://en.wikipedia.org/wiki/Cronjob) to decrease you administrative work.You normaly just have to change the config variables.Script 1: Auto RO server restart when crashed(should be started via cronjob every 5 minutes or less) #!/bin/bash ###CONFIG START### SERVER_USER="foo" PATH_TO_RO="/home/bar/rathena/" ###CONFIG END### ERROR=0 if [ "$(ps auxf | grep 'login-server' | grep -v 'grep')" == "" ]; then ERROR=1 fi if [ "$(ps auxf | grep 'char-server' | grep -v 'grep')" == "" ]; then ERROR=1 fi if [ "$(ps auxf | grep 'map-server' | grep -v 'grep')" == "" ]; then ERROR=1 fi if [ $ERROR == 1 ]; then su $SERVER_USER | $PATH_TO_RO/athena-start restart fi Script 2: SQL Backup(should be started every day) #!/bin/bash ###CONFIG START### PATH_TO_BACKUPS="/home/foo/backups" DB_HOST="localhost" DB_USER="foo" DB_PASSWORD="secretpw" WHICH_DATABASES="ragnarok" USER_NAME="foo" USER_GROUP="bar" ###CONFIG END### find -P $PATH_TO_BACKUPS -maxdepth 1 -type f \( -name '*.sql' \) -ctime +15 -exec rm {} \; mysqldump -h$DB_HOST -u$DB_USER -p$DB_PASSWORD --databases $WHICH_DATABASES > $PATH_TO_BACKUPS/$(date +%Y-%m-%d).sql chown $USER_NAME:$USER_GROUP $PATH_TO_BACKUPS/$(date +%Y-%m-%d).sql Script 3: Logs -> History DB If you have the logs and ragnarok tables in the same database, you can may think of archive some of old logs to another database.(should be started 2 times a month) #!/bin/bash ###CONFIG START### PATH_TO_RO="/home/bar/rathena" DB_HOST="localhost" DB_USER="bar" DB_PASSWORD="secretpw" DB_RAGNAROK_DATABASE="ragnarok" DB_LOG_DATABASE="ragnarok-log" ###CONFIG END### mysqldump -h$DB_HOST -u$DB_USER -p$DB_PASSWORD --compact --no-create-info $DB_RAGNAROK_DATABASE atcommandlog branchlog charlog chatlog npclog picklog zenylog > $PATH_TO_RO/temp.sql mysql -h$DB_HOST -u$DB_USER -p$DB_PASSWORD -D$DB_RAGNAROK_DATABASE -e"DELETE FROM atcommandlog WHERE 1=1; DELETE FROM branchlog WHERE 1=1; DELETE FROM charlog WHERE 1=1; DELETE FROM chatlog WHERE 1=1; DELETE FROM npclog WHERE 1=1; DELETE FROM picklog WHERE 1=1; DELETE FROM zenylog WHERE 1=1;" mysql -h$DB_HOST -u$DB_USER -p$DB_PASSWORD -D$DB_LOG_DATABASE < $PATH_TO_RO/temp.sql rm $PATH_TO_RO/temp.sql (before you start this script, you should insert a structure only dump into your history database) I hope this may help you and the config is understandable.Greetings,Loki1991(before you start this script, you should insert a structure only dump into your history database) Edited January 31, 2014 by loki1991 7 Quote
imajhaynation Posted January 11, 2013 Posted January 11, 2013 thankyou more scripts to come bro Quote
icabit Posted January 19, 2013 Posted January 19, 2013 (edited) any link for this? Edited January 19, 2013 by icabit Quote
Brian Posted January 20, 2013 Posted January 20, 2013 All of the Linux shell scripts are in QUOTE boxes in post #1. 1 Quote
hexor9 Posted April 10, 2013 Posted April 10, 2013 Script 3: Logs -> History DB(should be started 2 times a month) Quote #!/bin/bashmysqldump -hDBSERVER_IP -uDB_USER -pDB_PASSWORD --compact --no-create-info RAGNAROK_DB atcommandlog branchlog charlog chatlog npclog picklog zenylog > PATH_TO_RO/temp.sqlmysql -hDBSERVER_IP -uDB_USER -pDB_PASSWORD -DRAGNAROK_DB -e"DELETE FROM atcommandlog WHERE 1=1; DELETE FROM branchlog WHERE 1=1; DELETE FROM charlog WHERE 1=1; DELETE FROM chatlog WHERE 1=1; DELETE FROM npclog WHERE 1=1; DELETE FROM picklog WHERE 1=1; DELETE FROM zenylog WHERE 1=1;"mysql -hDBSERVER_IP -uDB_USER -pDB_PASSWORD -DHISTORY_DB < PATH_TO_RO/temp.sqlrm PATH_TO_RO/temp.sql (before you start this script, you should insert a structure only dump into your history database)how to make crontab by here * * * * * (before you start this script, you should insert a structure only dump into your history database) and also this HOW Quote
loki1991 Posted January 31, 2014 Author Posted January 31, 2014 Now the "markers" are variables. Quote
Brave Posted May 5, 2014 Posted May 5, 2014 Now the "markers" are variables. hello how would i apply this? i haven't done any cronjobs and as i see the comment it is really good can you teach me how? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.