Jump to content

How To Make A Cli Script


bobs@sectorlink

Recommended Posts

I found articles: https://docs.blesta.com/display/dev/Plugin+Cron+Tasks and https://docs.blesta.com/display/user/System+%3E+Automation#System>Automation-RunningtheCronManually and I see example code from /var/www/blesta/plugins/auto_cancel/auto_cancel_plugin.php . I don't want to run a job every day and don't want to bother with the install code for this.... I've got a plugin working via the web site, but need to run it from CLI (Command Line Interface).

 

I just want to create my own Linux Cron job that runs once a month, so I am wondering what I need for the command line [sudo crontab -e]:

@monthly "/usr/bin/php index.php /plugin/hourly/main/invoices/"

 

Sorry, I don't have direct access to the server to play with the path, or I wound not be asking how to do this. I've looked at the file /var/www/blesta/config/routes.php, but an stuck... It looks like the path may need to be something like: admin/api/plugin/hourly/main/invoices/ ? Any pointers on this?

 

Here is my /var/www/blesta/plugins/hourly/controllers/main.php controller file:

class Main extends HourlyController {

 

  public function preAction() {

    parent::preAction();

  }

 

  public function invoices() {

    Loader::loadModels($this, array("Hourly.HourlyInvoice"));

    $this->HourlyInvoice->start_invoices();

  }

 

}

Link to comment
Share on other sites

You will add your plugin to /blesta/plugins/  foldler ,here is developer doc. https://docs.blesta.com/display/dev/Creating+a+Plugin

 

Example

 

/blesta/

  /plugins/ your_plugin/

                 controllers/

                 models/

                 views/

                 controller.php

                 config.json

                 ...etc

Link to comment
Share on other sites

  • 5 weeks later...

Thanks, Nelsa. I was able to make my plugin work via the site now, but am stuck on how to get it to work on the Console (Command Line Interface for Linux).

 

What should I try for the /usr/bin/php index.php [PATH to the controller]? /plugin/hourly/main/invoices/ works on the site, but I'm not familiar enough with how Blesta routes the plugin via command line.  

Link to comment
Share on other sites

Thanks, Nelsa. I was able to make my plugin work via the site now, but am stuck on how to get it to work on the Console (Command Line Interface for Linux).

 

What should I try for the /usr/bin/php index.php [PATH to the controller]? /plugin/hourly/main/invoices/ works on the site, but I'm not familiar enough with how Blesta routes the plugin via command line.  

 

 

normally for the cron you should use another controller rather than the admin controller , so the admin controller need to be the admin logged in to work .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...