I. Создаем файл с названием autocash_cron в папке /etc/cron.hourly или в любой другой /rtc/cron.* II. Записываем там строки (/here/comes/the/directory/of/this script - путь к autocash.sh из корневого каталога. Например /var/root/script) #!/bin/bash cd /here/comes/the/directory/of/this script ./autocash.shСохраняем и выдаем права на файлы chmod 755 autocash_cronchmod 777 autocash.shНиже содержимое autocash.sh сщщтветственно. host,user,pass,auth_db,cash изменить под себя. Логи лежат в /home/8.cashsystem/ тоже можно изменить под себя #!/bin/bash##Version=1.2#MySQL Script to set autocash on your LastChaos Database#Created by Attitude-Gaming-Network##Create a file called "autocash_cron" in "/etc/cron.hourly" to run it automatically every hour. #Write in this file following lines #!/bin/bash# cd /here/comes/the/directory/of/this script# ./autocash.sh#Save and make sure you have the right permissions "chmod 755 autocash_cron" and "chmod 777 autocash.sh" on it.#Now the account which each hour is online gets your specified cash.#Put your settings to enable connect to your MySQL Server and how much cash will be added.#For security reasons use this script only on localhost which your database is running. host=user=pass=auth_db=cash=date=`date +"%d-%m-%Y %H:%M"`date2=`date -I`#Cash-Scriptselect=`mysql -D $auth_db -h $host --user=$user --password=$pass --skip-column-names -e "SELECT a_portal_index FROM t_users WHERE a_zone_num > -1"`for online in ${select[@]}do setcash=`mysql -D $auth_db -h $host --user=$user --password=$pass --skip-column-names -e "UPDATE bg_user SET cash = cash +'$cash' WHERE user_code = '$online'"`done#Create a logfile to your specified path how much Accounts was online and how much cash was added. (место для логов)
echo "Succesfully $amount Cash added distributed $id Accounts."#Writes the name of the account and their ip which was online at the moment from the cronjob in your logfile. (Опять же, логи) path="/home/8.cashsystem/cashlogfile_$date2.txt" ip=`netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n` echo -e "">> $path echo -e "Connections:\n">> $path echo -e "$ip">> $path echo -e "">> $path cd /home/8.cashsystem/sed '/host/!s/.*127.0.0.1*/Na dann geh mal kicken :)/g' cashlogfile_$date2.txt > cashlogfile_$date2.txt.newsed '/host/!s/.*Address.*//g' cashlogfile_$date2.txt.new> cashlogfile_$date2.txt.new2sed '/host/!s/.*servers).*//g' cashlogfile_$date2.txt.new2 > cashlogfile_$date2.txt.new3rm -rf cashlogfile_$date2.txtmv cashlogfile_$date2.txt.new3 cashlogfile_$date2.txtrm -rf cashlogfile_$date2.txt.new3 cashlogfile_$date2.txt.new cashlogfile_$date2.txt.new2
5 MINUTE,2014-08-06 00:34:11,newproject_auth.bg_user,25 - изменить под себя. Выполнить запрос к бд. SET GLOBAL event_scheduler = ON;CREATE EVENT `OnlineCashAdd` ON SCHEDULE EVERY 5 MINUTE STARTS '2014-08-06 00:34:11' ON COMPLETION PRESERVE ENABLE COMMENT '' DO UPDATE newproject_auth.bg_user SET cash = cash +25 WHERE user_code IN (SELECT a_portal_index FROM newproject_auth.t_users WHERE a_zone_num !=-1)