collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Starting Bot as a service on a Linux system  (Read 15184 times)

0 Members and 1 Guest are viewing this topic.

Offline tsafarog

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Starting Bot as a service on a Linux system
« on: November 10, 2010, 11:45:04 am »
Hello guys,

need your help

I am running the Bot through an SSH client always by giving the php5 command. The problem is that when my SSH client crash for a reason the Bot disconnects. Is there a way to start the Bot as a service so i wont have to relog when the Bot crash and will not have to pay so much attention to it??

Thank you in advance

Offline Getrix

  • Contributor
  • *******
  • Posts: 509
  • Karma: +0/-0
Re: Starting Bot as a service on a Linux system
« Reply #1 on: November 10, 2010, 12:53:19 pm »
Have a look on "screen" function in linux
Success is not final, failure is not fatal: it is the courage to continue that counts.
- Sorry, i dont have time to reply question on PM. Make a topic.

Offline Yite

  • BeBot Apprentice
  • ***
  • Posts: 152
  • Karma: +0/-0
    • Niflheim - Crom
Re: Starting Bot as a service on a Linux system
« Reply #2 on: November 10, 2010, 12:55:51 pm »
Yup works great in screens (running multiple bots each in their own 'screen') for some more information check out Getrix' comments here: http://bebot.link/ao-0-6-support/how-to-recall-logginf-screen-of-bebot-%28ssh%29/msg12028/#msg12028
-Yite [Crom]

Offline tsafarog

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Starting Bot as a service on a Linux system
« Reply #3 on: November 10, 2010, 01:04:58 pm »
i know what you mean....

But my problem is for example when i am away from home ..... i dont want to have my pc running putty all the time. What if it crashes when i am not home? I am not familiar with the screen command. If i setup screen, will i be able to close SSH and bot will keep running???


Offline Yite

  • BeBot Apprentice
  • ***
  • Posts: 152
  • Karma: +0/-0
    • Niflheim - Crom
Re: Starting Bot as a service on a Linux system
« Reply #4 on: November 10, 2010, 02:28:21 pm »
yeah basically what you do is you create a screen session (from memory screen -s sockname)

In this session you will start your bot
to leave the screen session press ctrl-a ctrl-d (or just ctrl-a d can't remember)

At any point you want to check up on the session run:
screen -r name (or just screen -r to see a list of screens)

If your ssh session dies your bot will keep on running.
-Yite [Crom]

Offline tsafarog

  • BeBot Rookie
  • *
  • Posts: 9
  • Karma: +0/-0
Re: Starting Bot as a service on a Linux system
« Reply #5 on: November 12, 2010, 10:47:15 am »
Thank you very much for your help problem solved

Offline Shelly

  • BeBot Apprentice
  • ***
  • Posts: 192
  • Karma: +0/-0
Re: Starting Bot as a service on a Linux system
« Reply #6 on: September 25, 2011, 10:56:39 pm »
If you are only running a single bot... you can also do

to keep a log:
nohup /usr/bin/php -f <bothome>/StartBot.php <botname> 2>&1 > <bothome>/<botname>.log &

or to maintain space:
nohup /usr/bin/php -f <bothome>/StartBot.php <botname> 2>&1 > /dev/null &

I use a script to start my bots so I don't have to remain logged into the server...
start_<botname>.sh
Code: [Select]
#!/bin/bash
 
#
##
### Check for AO Bots and restart if necessary
##
#
# This script looks to see if your bot is actually running and does nothing if it is
# already running.
# If it is not running, it will email you the previous log, then compress it to concerve space.

# The BOT* items you will need to configure for your bot.
BOTHOME="/home/bot/BeBot"
BOTNAME="Your_Bot_Character_Name"
BOTLOGS="/home/bot"
BOTLOG_Archive=${BOTLOGS}/log_archive

mdate=`date +%b-%d-%Y`;
hdate=`date +%b-%d-%Y_%H%M_hrs`;

z=`ps -ef |grep ${BOTNAME} |grep -v grep`;
if [[ $z == "" ]]
then {
  # comment this next line out if you don't want the previous log emailed to you.
  mailx -s "Starting ${BOTNAME} bot " [email protected] <${BOTLOGS}/${BOTNAME}.log ;
  if [ -e "${BOTLOGS}/${BOTNAME}.log-${mdate}.Z" ]
  then {
    mv ${BOTLOGS}/${BOTNAME}.log ${BOTLOG_Archive}/${BOTNAME}.log-${mdate};
    /usr/bin/compress ${BOTLOG_Archive}/${BOTNAME}.log-${mdate};
  }
  else {
    mv ${BOTLOGS}/${BOTNAME}.log ${BOTLOG_Archive}/${BOTNAME}.log-${hdate};
    /usr/bin/compress ${BOTLOG_Archive}/${BOTNAME}.log-${hdate};
  };
  fi
  cd ${BOTHOME}; /usr/bin/php -f ${BOTHOME}/StartBot.php ${BOTNAME} 2>&1 > ${BOTLOGS}/${BOTNAME}.log &
}
fi

#EOF
« Last Edit: September 25, 2011, 11:07:58 pm by Shelly »

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 287
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal