L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 07, 2008, 04:43:32 AM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Support > Helpful posts > Topic: Bot Check on Linux
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Bot Check on Linux  (Read 989 times)
0 Members and 1 Guest are viewing this topic.
Shelly
Freshman
*
Offline Offline

Posts: 11


Bot Check on Linux
« on: September 05, 2005, 08:50:16 AM »

I created a small perl script to make sure my bot is running and haven't seen anything like it on the boards, so I am sharing it here.

Shelly

bot_check.pl
#!/usr/bin/perl

# Author: Shelly
# Notes:
# 1. Replace all "YourBotName" with what ever the name of your bot.
# 2. Replace your_account\@your_mail_host with the email address you want to recieve your
# logs and notifications at.
# 3. I also place the bot in it's own directory (YourBotName), but save the logs in bebot's home directory.
# This way I can run multiple bots.
# 4. Crontab Entry for Fedora Core/ Vixie Cron
# 0/10 * * * * cd /home/bebot; ./bot_check.pl >/dev/null

#
##
### Check for AO Bots and restart if necessary
##
## bebot 12007 11929 0 11:45 pts/0 00:00:00 php -f YourBotName/start.php
#

$mdate = `date +%b-%d-%Y`;

$z = `ps -ef |grep YourBotName |grep -v grep`;
chop($z);
if ($z eq "")
{
system("mail your_account\@your_mail_host -s \"Starting YourBotName bot on web1\" </home/bebot/YourBotName.log");
system("mv /home/bebot/YourBotName.log /home/bebot/YourBotName.log-${mdate}");
system("cd /home/bebot; /usr/local/bin/php -f /home/bebot/YourBotName/start.php > /home/bebot/YourBotName.log &");
}
Logged
redman
Freshman
*
Offline Offline

Posts: 1


Bot Check on Linux
« Reply #1 on: September 06, 2005, 06:28:15 AM »

if you can check, you should be able to autorestart it with that script either or ?

sorry my fault it restarts it automatically as far asi can see now.
cool script thx very much will try it out this weekend ...
Logged
laen
Rookie
**
Offline Offline

Posts: 21


Re: Bot Check on Linux
« Reply #2 on: February 16, 2008, 01:42:55 PM »

Made a bash script, and since i'm running multiple bots, check the botname, and bot dir.

  • Works if you're running bots as:
Code:
php -f StartBot.php <botname>
  • Logs are saved in the bot's logdir, with .log instead of .txt.

The script:
Code:
#!/bin/bash
### bot crontab script by laen@onedot.nl
###
### run as <script_name> <bot_dir> <bot_name> <bot_dimension (1, 2 or 3)>

# code
if [ ! "`ps x -o args | grep "php -f StartBot.php "$2"" | grep -v grep | cut -d " " -f 4`" = "$2" ]; then
        cd "$HOME"/"$1"/; php -f StartBot.php $2 >> log/`echo "$2" | tr "A-Z" "a-z"`\@RK"$3"/`date +%Y-%m-%d.log` 2>&1 &
fi

Example crontab:
Code:
*/5 * * * * /home/user/bot_check.sh bots/org Botty 1
« Last Edit: February 17, 2008, 03:15:34 PM by lcidw » Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Support > Helpful posts > Topic: Bot Check on Linux
« previous next »
 
Jump to:  

Recent
TWC
by Temar
[Today at 02:49:27 AM]

raid/point system suggest...
by Vain
[October 06, 2008, 08:53:00 PM]

!items database
by cthulhu
[October 05, 2008, 11:36:16 AM]

Supplies needed module
by viper
[October 05, 2008, 11:11:13 AM]

Assist
by Foxy
[October 05, 2008, 05:09:02 AM]

How's 0.5.x coming? Wonde...
by Hyde
[October 04, 2008, 04:59:20 PM]

Org in AoC
by Alreadythere
[October 04, 2008, 04:50:00 AM]

OnlineOrg
by Slacklin
[October 04, 2008, 03:06:00 AM]

Learning .NET, Mono, C#, ...
by Vhab
[October 04, 2008, 02:39:03 AM]

guild taxes module for ag...
by Elesar1
[October 03, 2008, 09:06:09 AM]
Stats
Members
Total Members: 983
Latest: Titerris
Stats
Total Posts: 10743
Total Topics: 1448
Online Today: 10
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 4
Guests: 46
Total: 50
Noer
Wolfbiter
Temar
IKShadow

Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.174 seconds with 28 queries. (Pretty URLs adds 0.035s, 4q)
Loading...