User login

How to restart Drupal bot (and wish to automatically restart)

The first start

cd /home/members/agariclabs/sites/
php bot_start.php --root /home/members/agariclabs/sites/ --url

Older discussion about restarting below (uses test server paths)

To restart your friendly neighborhood drupal bot when it no longer responds to commands, first kill the zombie bot for real.

When you kill it, the bot disappears from the channels so you don't have to kick it out, and the re-started bot will be able to claim its proper name.

On the server on which the bot module and bot_start.php is running:
ps -C "php bot_start" -opid | grep "[0-9]"

This gives you the pid, which you can use to kill the process.

Second, start up the bot, from the bot module's README.txt:

php bot_start.php --root /var/www/myagaric/drupal --url

(I don't even know how it gets by the http authentication pop-up on our test site, but this works.)

But just using this the new bot will disconnect when the SSH connection to the server disconnects. More is needed to disassociate a process from the shell.

According to stefan-agaric: In zshell it's done with & disown or & !. should be the same in bash

kill `ps -C "php bot_start.php" -opid | grep "[0-9]"`
php /var/www/myagaric/drupal/sites/default/modules/bot/bot_start.php --root /var/www/myagaric/drupal --url

Rather than automatically restarting drupalbot when it freezes and stops responding in (or logging) its channels ("drupal bot module automatically restart" turns up nothing, though I think it does get restarted automatically in #drupal), Stefan ran the above script nightly to keep everything running smooth and fresh.

Starting a new one, prior to cron being set up:
php /var/local/drupal/mayfirstsupport/web/sites/all/modules/bot/bot_start.php --root /var/local/drupal/mayfirstsupport/web --url &

Stefan has turned the above into a script we can call from cron jobs (set up the cron job with crontab -e). Here is the script, which lives at /home/stefan/druplicon.


if [ -z "$1" ]
        echo "Usage: `basename $0` project-name"
        exit $E_NOARGS


kill -9 `ps -C "php" -o pid,cmd | grep "${PROJECT}/.*/bot_start\.php" | awk -F ' ' '{print $1}'`
php /var/local/drupal/${PROJECT}/web/sites/all/modules/bot/bot_start.php --root /var/local/drupal/${PROJECT}/web --url https://${PROJECT}

To see what cron jobs are set up on the test server:

sudo su
grep * /var/spool/cron/crontabs/*

Currently this is:

/var/spool/cron/crontabs/ben:23 5 * * * /home/stefan/druplicon mayfirstsupport
/var/spool/cron/crontabs/stefan:52 3 * * * /home/stefan/druplicon myagaric


Alternative to restarting nightly

dkg reccomends: just set a ulimit on RAM and run it under some sort of supervision

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.