diggersworld
diggersworld

Reputation: 13080

Setting up cron job with Bolt on Plesk 11.5.30

I'm trying to setup a cron job with Bolt.cm via the Plesk 11.5.30 admin console.
Bolt task scheduler documentation: https://docs.bolt.cm/v20/tasks

Scheduled Tasks

I have setup crontab for the apache user as follows:

Min     H     DM     M     DW     Command
0      */1     *     *     *      /var/www/vhosts/mysite.com/httpdocs/app/nut cron
0      */1     *     *     *      httpdocs/app/nut cron

The reason for two different commands here is that I've read in another thread troubleshooting Plesk that the command path should be relative from the domain. I assume if the first one fails, the second will still run. I also assume the above will run cron every hour.

Bolt Config

In my config file the cron_hour is set to 3am. However as the listener is set for an hourly event CRON_HOURLY I assume the setting is bypassed/ignored. Either way this setup has been running for over 48 hours and no effect has yet been witnessed.

Bolt Setup

As a test I have added the following into my Bolt extension so that it should simply send me an email when it is run (the following has been cut down to keep it short).

use \Bolt\CronEvents;

class Extension extends \Bolt\BaseExtension 
{
    function initialize() {
        $this->app['dispatcher']->addListener(CronEvents::CRON_HOURLY, array($this, 'cronNotifier'));
    }

    function cronNotifier() {
        // send email script...
    }
}

I've tested my email script individual so I know it works. With the cron job setup and assumed to be running this function is never hit. What's more is that in the database the bolt_cron table remains to be empty.

If anyone could help suggest some things I could try to get this running it would be greatly appreciated.

THE FIX

In order to fix this issue I altered my schedule to execute every 5 minutes (quicker debug loop). I then made the following discoveries:

Thanks @Gawain for prompting me in the right direction.

Upvotes: 2

Views: 513

Answers (1)

Gawain
Gawain

Reputation: 1568

Scheduled Tasks

Yes, that looks correct. The handling of directory locations was enhanced recently, but you used to need to call nut from in the Bolt directory.

Bolt Config

cron_hour only applies to daily, and longer periods. There was a bug I fixed recently that was blocking out midnight to 3 am hourly tasks.

OK, there should be traces logged in the Bolt log about running cron events.

If you run this, do you see the hourly job trigger and your email sent?

./app/nut cron --run=cron.Hourly

If that works, then the problem is with the system cron/crontab, if editing directly were you using crontab -e?

Also if you're on an older checkout of master, you can try to prefix the crontab command section with

cd /var/www/vhosts/mysite.com/httpdocs &&

...before each invocation of ./app/nut

Upvotes: 1

Related Questions