egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to successfully setup crontab for your bot on your shell

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Shell & Bouncer Help
View previous topic :: View next topic  
Author Message
Sane
Voice


Joined: 17 Nov 2013
Posts: 15
Location: #kl-channel@Rizon.net

PostPosted: Mon Nov 18, 2013 9:16 am    Post subject: How to successfully setup crontab for your bot on your shell Reply with quote

The following guide was written for myself. After much trial and error I finally managed to setup crontab to auto-restart my eggdrop bot correctly. I have tweaked the guide so that it will apply to others.

This guide is as long and as comprehensive as it needs to be so that anyone is able to follow and understand how to set up crontab correctly after they've read this.

START----------
Essential things to remember (in my opinon):
1) Remember that CaPiTaLiSaTiOn on LiNuX counts, if you try to access a file or directory for example, by typing a few letters of its title into the shell window and hitting tab to auto-complete the rest of the file or directory's title, it will not work if you started the first letter of the title with a lower case letter if the actual file or directory starts with an UPPER CASE letter and visa versa.

2) Remember that when a slash is missing off the very end of a path, it means that the text on the very end is a file. if there IS a slash at the very end of said path then that text at the very end of that path is a directory/folder.

3) Also remember about the 'c<hange>d<directory>' command. You would 'cd' to your bot's folder when you want to execute it with 'eggdrop eggdrop *.conf' which launches your bot into the background. for example, you want to start your bot from the shell window but it won't work 'cause you tried to run your bot from the wrong location - How to fix? Lets say that you're in the path of 'yourusername' directory and that your bot is called 'LamestBot', and is in a folder of the same name (which holds all your eggdrop files, .conf,scripts,etc.), and that, that folder is located in 'yourusername' directory - you would type 'cd LamestBot' (or 'cd lame + TAB' to auto-complete the rest of the name), to change the path from '/home/yourusername/' to '/home/yourusername/LamestBot/, now you're in the correct directory and the problem is fixed, then you would type 'eggdrop eggdrop *.conf' to launch your bot.

4) Remember to type 'ps x' into your shell window when you want to see what processes/tasks you have runnning in the background.

5) Remember when you want to kill your bot, you can kill it in the following ways: by typing '.die' into the telnet version of the bot's party line - by typing '.die' into the ctcp version of the bot's partyline - by having and using a script that sends the bot the 'die' command either by an in-channel trigger, a notice or a private message to the bot, or even in a memo in some instances - and by using either 'pkill eggdrop' or 'kill all eggdrop' + many other kill variations in your Linux shell terminal.

6) Remember 'pwd' (print working directory) will show the current path you're in on your linux shell window/terminal session.

7) (very important) Remember that you must have the 'eggdrop binary executable' and the 'botchk' file in your eggdrop bot's main directory; where your 'eggdrop *.conf' is located. e.g. these would be the paths of those two files once you copied them to the correct location: 'eggdrop binary executable' path: /home/yourusername/yourbot'sfoldername/eggdrop - and the 'botchk' path: /home/yourusername/yourbot'sfoldername/botchk - you can find the 'eggdrop binary executable' when you compile your bot on a Linux system (if using a windrop like I am <technically a hybrid version but whatever> just copy the 'eggdrop binary executable' from where-ever you get it from into the above path, making sure it was compiled for the same version of eggdrop you're using) - you can find the botchk file in your bot's 'scripts' folder (/home/yourusername/yourbot'sfoldername/scripts/.

8) I cannot stress this enough - when you see 'eggdrop eggdrop *.conf' it means if you've called your bot's config file something else then you'd start your bot like this: eggdrop THEDIFFERENTNAMEYOUGAVEYOURCONFIG.conf, otherwise just 'eggdrop eggdrop.conf'
DONE----------

START~~~~~~~~~~~~~~~
Guide starts here:

1) Edit the first line of your eggdrop.conf from this:
#! /path/to/executable/eggdrop - into this for e.g.
#!/home/sane/Bollox/eggdrop - 'sane' replaced by your username, 'Bollox' replaced by the name of your bot's folder.

2) Make sure you have the 'botchk' and the 'eggdrop binary executable' files in your bot's main directory; where your 'eggdrop *.conf' is located. The 'eggdrop *.conf' that you just changed the first line of to look like this: #!/home/yourusername/yourbot'sfoldername/eggdrop.

3) Okay now, make sure you're in the correct path in your shell window, and that you stay in that correct path throughout this whole crontab process: '/home/yourusername/yourbot'sfoldername/', now you're going to want to type these two commands one at a time into the shell window: 'chmod u+x eggdrop' and 'chmod u+x botchk' - or chmod 700, stick with u+x though, which is equivalent to 744. These commands will grant only the owner of those files I.E YOU execution permissions, that's what the 'u' stands for, 'you', and what the 'x' stands for is.. 'executable'. You'll know that this worked if you type 'ls' into the shell window and you see that those two files that you chmoded are now coloured in green text.

4) Next edit the 'botchk' file by typing 'pico botchk' into the shell window, edit it so there's no " ./ " (dot slash) in it at all. (total of 3) (just backspace the " ./ " <dot slashes> out) (e.g. " ./$botscript " - backspace the slash and dot out so it's just '$botscript') (control + w in pico is equivalent to control + f<ind> on Windows)

5) While still in 'pico' edit the coloured info in the 'botchk file', edit the default coloured text to look exactly like the following table below. Note: This info in brackets applies to the below table in code -->(REMEMBER TO MAKE SURE THERE'S A SLASH AT THE BEGINNING OF 'home', so '/home' - VERY IMPORTANT, AND MAKE SURE THERE'S A SLASH AFTER 'yourbot'sfoldername', so 'yourbot'sfoldername/' - VERY IMPORTANT, so it should look like this: '/home/yourusername/yourbot'sfoldername/') (ALSO, NO ./ <DOT SLASH> INFRONT OF " eggdrop eggdrop *.conf " - VERY IMPORTANT)

-6)-
Code:
Table:
# change this to the directory you run your bot from (capitalization COUNTS):
botdir="/home/yourusername/yourbot'sfoldername/"

# change this to the name of your bot's config file (capitalization COUNTS):
botscript="eggdrop eggdrop *.conf"

# change this to the botnet-nick of your bot (capitalization COUNTS):
botname="yourbot'snick"

# change this to the name of your bot's userfile (capitalization COUNTS):
userfile="yourbot'snick.user"

# change this to the name of your bot's pidfile (capitalization COUNTS):
pidfile="pid.yourbot'snick"

########## you probably don't need to change anything below here ##########


7) After you're finished editing the 'botchk' file you're going to want to hit control + o to save, then hit Enter to keep the same file name of 'botchk', then hit control + x to exit out of pico.

8) Next type 'pico crones' into the shell window, this will open up the current crones file for editing or create a new crones file if there isn't one there - "there" being the path directory you were in when you executed the command - so '/home/yourusername/yourbot'sfoldername/'

9) Now paste following after the colon into the crones file:
0,10,20,30,40,50 * * * * /home/yourusername/yourbot'sfoldername/botchk >/dev/null 2>&1

10) Then hit control + o to save, then hit Enter to keep the same file name of 'crones', then hit control + x to exit out of pico.

11) Next you're going to want to delete any crontabs you already have stored by typing 'crontab -r'(sometimes -d) into the shell window; which will delete all crontabs stored. (Not essential, but I'd reccomend doing it)

12) Next type 'crontab crones' into the shell window, this will add the line you copied into the 'crones' file into a new crontab, then type 'crontab -l' to list all crontabs, the crontab you just added should appear on a new line and should be the only crontab you see there.

13) After all that you're going to want to type the following into the shell window: './botchk eggdrop *.conf' (./botchk THEDIFFERENTNAMEYOUGAVEYOURCONFIG.conf, otherwise just './botchk eggdrop.conf')

14) It should work now, your bot should launch normally, just like if you're using 'eggdrop eggdrop *.conf'

15) Next try: './botchk eggdrop *.conf' again (while your eggdrop is already running, check with 'ps x' to make sure it is; check IRC too), nothing should happen and you should see nothing happen in the shell window, the next thing to do is to kill the bot and just wait and see if crontab starts the bot by itself, if the bot does start then crontab sucessfully started botchk which sucessfully started the bot by itself.
END~~~~~~~~~~~~~~~

..........

Protip: check the dead.letter file that will inevitably be created in the '/home/yourusername/' directory, and by check I mean 'pico dead.letter' (control + x to exit pico), this file (in this case, my dead.letter) should show you something like this:
sane@*irrelevant*:~$ pico dead.letter
GNU nano 2.2.2 File: dead.letter




Couldn't find bot 'Bollox' running, reloading...

[19:20] --- Loading eggdrop v1.6.19+SSL (*date irrelevant*)
[19:20] Listening at telnet port *irrelvant* (*irrelvant*).
[19:20] Module loaded: blowfish
[19:20] Module loaded: dns
[19:20] Module loaded: channels
[19:20] Module loaded: server
[19:20] Module loaded: ctcp
[19:20] Module loaded: irc
[19:20] Module loaded: notes (with lang support)
[19:20] Module loaded: console (with lang support)
[19:20] Module loaded: seen
[19:20] Module loaded: uptime
[19:20] MegaHAL v3.5 by ^Baron^ loaded.
[19:20] Module loaded: megahal
[19:20] ^C0,1 ^CLoaded: Ident
[19:20] ^C0,1 ^CLoaded: ^C0,1^B BaOSS ^B^C
[19:20] ^C0,1 ^CLoaded ^B^C0,1TV^C4,1rage^B^C
[19:20] ^C0,1 ^CLoaded: R4Nd
[19:20] ^C1,1 ^CLoaded: ^C9,1^B WIN ^C0,4 FAIL ^C
[19:20] ^C0,1 ^CLoaded: ^C1,15Dice
[19:20] % youtube_title0.5: loaded
[19:20] peak1.8.tcl by FireEgl@EFNet <EggTCL@FireEgl.CJB.Net> - Loaded.
[19:20] troll.tcl v2.0 by spithash@DALnet iz up and trollin'
[19:20] - incith:google-1.8.8g loaded.
[19:20] google.tcl 0.31 loaded
[19:20] beer.tcl v.1.beta1 by SpiKe^^ loaded
[19:20] - UNOFFICIAL incith:google-2.0.0b loaded.
[19:20] IMDB info version 19.10.2010 loaded
[19:20] youtube getlink v 0.1 by hwk loaded
[19:20] Urban.tcl 2.0 by Trixar_za Loaded
[19:20] ^C04Modern Roulette Made By Dopeydwerg Loaded
[19:20] Loaded RemoveBans (DLF)
[19:20] - ^BSex Dice^B version 1.0a loaded.
[19:20] Insult.tcl v1.02 by David Proper (DrN) -: LoadeD :-
[19:20] ^C0,1 ^CLoaded: ^C8,4^B MOAR
[19:20] ^C0,1 ^CLoaded: ^C13,1^B NAOW
[19:20] ^C0,1 ^CLoaded:^B^C4,1 KUTGW. :)
[19:20] Url Title Grabber 0.01a (rosc) script loaded..
[19:20] incith:horoscope-3.2: loaded.
[19:20] ^B*Loaded* ^B^C01,11-FML-^B^C ^BRandom by Ford_Lawnmower irc.GeekShed.net #Script-Help
[19:20] * easyspeak-Me_Only.tcl by Dalanx loaded.
[19:20] ^C4KnK Script v1.0 by Ian Preglo and Marluo Anuengo has been loaded.^C
[19:20] bMotion 0.1.0 starting up...
[19:20] loaded fact module
[19:20] bMotion: new installation, need to send stats/check version...
[19:20] bMotion: diagnostics indicate you haven't loaded the userinfo TCL script
[19:20] this is not required, but is strongly recommended
[19:20] ^BbMotion 0.1.0 AI online^B :D
[19:20] bMotion is Copyright (C) 2007 James Seward. bMotion comes with ABSOLUTELY NO WARRANTY;
[19:20] This is free software, and you are welcome to redistribute it under certain conditions.
[19:20] See the COPYRIGHT file for details. See bMotion.tcl to hide this message once you have read it.
[19:20] Loaded STFU Script - By Sane (irc://irc.rizon.net/kl-channel)
[19:20] Weatherscript from Djoezy loaded - version v1.1
[19:20] Public whois script 0.10 by MeTroiD, #v1per on Quakenet
[19:20] ^B*Wicked Flame script LOADED v0.1 by jastarafi*
[19:20] Brain learning mode set to on
[19:20] YouTube 1.3 loaded
[19:20] Loading dccwhois.tcl...
[19:20] Loaded dccwhois.tcl
[19:20] Identd: I don't know why you're using winident.tcl on your system, but it probably won't work on anything but Windows.
[19:20] winident.tcl v1.2 - by FireEgl@EFNet <FireEgl@Windrop.cjb.net> - Loaded.
[19:20] Userfile loaded, unpacking...
[19:20] === Bollox: 3 channels, 1 users.

Eggdrop v1.6.19+SSL (C) 1997 Robey Pointer (C) 2008 Eggheads

Eggdrop v1.6.19+SSL (C) 1997 Robey Pointer (C) 2008 Eggheads
Launched into the background (pid: *****)

..........

**********

The above contents of the 'dead.letter' file clearly shows that once your crontab (in this case mine) started your botchk file, the botchk file saw that your bot wasn't running at the moment/point in time that it checked, so the botchk file automatically did the equivalent of what you would do to load your bot yourself, and that is: 'eggdrop eggdrop *.conf' as specified in the botchk file when you were editing it, remember?

**********

Guide completely written by me, Sane, using my own words and researched info from a vast array of sources, but mainly my own initiative and lots of trial and error. NOTE: this crontab will start botchk every 10 minutes, which will then check if your bot is still running every 10 minutes. If when it checks, it finds your bot's already running then it will do nothing.

I don't wish for this guide to be copied anywhere else without my consent.
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Mon Nov 18, 2013 5:49 pm    Post subject: Reply with quote

why not just use autobotchk? located in the scripts dir
it will do all of the above automatically...



Code:
# AutoBotchk - An eggdrop utility to autogenerate botchk/crontab entries
#
# Copyright (C) 1999, 2000, 2001, 2002 Jeff Fisher (guppy@eggheads.org)
#
# How to use
# ----------
#
#   Most people begin to use AutoBotchk by moving it from the script
# directory to their Eggdrop directory -- this will save you from having to
# use the -dir option.
#
#   If you run AutoBotchk without any arguments, it will present you with
# a list of valid ones. Most people run AutoBotchk by doing:
#
#     ./autobotchk <config file>
#
#   This will setup crontab to check every 10 minutes to see whether or not
# your bot needs to be restarted and it will e-mail if a restart was
# performed. A lot of people turn off crontab e-mail support; however, I do
# not recommend this since you will be unable to see any errors that might
# happen.

_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
Sane
Voice


Joined: 17 Nov 2013
Posts: 15
Location: #kl-channel@Rizon.net

PostPosted: Mon Nov 18, 2013 7:11 pm    Post subject: Reply with quote

Well, mainly because I had issues with autobotchk in the past and I wasn't successful in setting it up properly before. Another reason is because I prefer to do it all manually so that way I know all the steps I took and everything I've edited, so it's less likely that any problems will arise.

So I just thought that I'd share my way of doing things, really.

Edit: autobotchk is cool to use too, if it works for you then great! If not then I'd just recommend using 'botchk' and do it all manually. It isn't really that much longer anyway. The entire process isn't actually long, the wall of text just makes it seem that way :P
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Mon Jun 02, 2014 11:33 am    Post subject: Reply with quote

Sorry for the thread bump, but should someone read this, they should know that there's a much easier and better method, the one that Doggo suggested.

Once you have compiled and set up eggdrop, configured your bot.conf file and everything runs perfectly, the next thing to do is the crontab. You can set up a crontab while the bot is online, this won't hurt it.

With everything already done in the ~/eggdrop directory, where your *.conf file is, we move on to the scripts directory.
Code:
cd ~/eggdrop/scripts


From here, we want to give autobotchk the correct permissions (you only need to do this once. If you have already set your autobotchk to 700, then just perform the last ./autobotchk command below).
Code:
chmod 700 autobotchk


Once that is done, we are left with 1 final command, which is setting the crontab. This is a one line command, easy to do, but please substitute the example text for the REAL names on your system.
So, if my eggdrop was installed to /home/getafix/eggdrop - and my bots config file was named 'example.conf' - then this final command will add the proper crontab, with 10min checks to make sure the bot is online.
Code:
./autobotchk example.conf -dir /home/getafix/eggdrop -noemail


This will add the crontab for you, checking every 10mins, and specifying the path/to/eggdrop and disabling those annoying restart emails. It is actually that simple, folks Smile
This information is on the EggHelp website, and can be found Here if you would like a second opinion Razz
_________________
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Sane
Voice


Joined: 17 Nov 2013
Posts: 15
Location: #kl-channel@Rizon.net

PostPosted: Mon Jun 02, 2014 8:37 pm    Post subject: Reply with quote

Hi, Get_A_Fix.

Thanks a lot for your input. As I mentioned previously, this guide was written for myself just in case I ever forgot how to do it and I just decided to share it with everyone else, and just added a few tweaks to it here and there. You see I had tried the other method that you and Doggo mentioned but I had difficulty in the past; something just wasn't working right then.

So I pretty much learned the basics and did it all manually ensuring that I knew what everything did, and how it all worked.

But yeah.. All I would say is: If 'your' method doesn't work for others, like if they run into difficulties like I did, then they should try 'mine', and visa versa.

Edit: It doesn't hurt to know how to do it manually. Although.. Knowing both ways could be beneficial.
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Tue Jun 03, 2014 12:00 am    Post subject: Reply with quote

Yep, it's always good to have one or more methods available. On this thread, there's the method you used, with crontab -e (this is the proper method for people who know how) while the method I showed is what eggdrop developers added for a quicker/faster way of creating the crontab entry. This is more common, since it is easier than using crontab, but occasionally if the eggdrop path or set up hasn't been done properly you may find issues develop. I do not know why it didn't work for you, but it's good to see you still managed to find a way Smile
_________________
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Shell & Bouncer Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber