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?
September 06, 2008, 09:45:28 PM

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 949 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: 20


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
Security
by Alreadythere
[Today at 10:02:42 AM]

Probs with relay from gue...
by Temar
[Today at 09:03:06 AM]

Raid spam in guild chat
by Temar
[Today at 09:01:18 AM]

Org Relaying
by Nytridr
[Today at 01:34:35 AM]

Link 2 Guilds via 2 Bots?
by Temar
[September 05, 2008, 04:22:40 PM]

SVN download
by clashbot
[September 05, 2008, 05:12:59 AM]

TWC
by Temar
[September 05, 2008, 12:27:23 AM]

How to find the guild ID?...
by Irinir
[September 03, 2008, 02:58:54 PM]

Deactivate Autoadding mem...
by Temar
[September 03, 2008, 02:49:01 PM]

0.4 Modules in 0.5 -- fou...
by Temar
[September 03, 2008, 11:06:42 AM]
Stats
Members
Total Members: 961
Latest: daltarak
Stats
Total Posts: 10408
Total Topics: 1412
Online Today: 15
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 1
Guests: 20
Total: 21
Jlee

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