Giter VIP home page Giter VIP logo

crontab's Introduction

This library is very simple, but it's designed to be so.


What does it do

This library sets up cron to perform tasks from crontab file.
When crontab file is written with this library. Almost all you
need is set up config/crontab.php file.


Installation

   1. Download library from github repository git://github.com/biozshock/crontab.git
   2. If you are familiar with phpunit you can test library. Tests are located in tests subdirectory
   3. Copy config/crontab.php and libraries/crontab.php
   4. Setup config/crontab.php
   5. Use this library


Crontab library config file

cronfile
    Path to cronfile library will write all jobs
php_path
    Path to PHP executable
crontime
    Crontab library default format for date() function
cli_path
    PHP cli scripts path
time_offset
    This config variable can be used when your server has different timezone
    from timezone of tasks you want to be cheduled. e.g. server is in -5 timezone.
    backend in +1 timezone. in backend you setting cronjob for 00:00:00,
    but for server this would be 14:00:00


Library usage examples

Simple usage

To execute cli script every day at midnight n your controller you should put following code:

$this->load->library('crontab');
$this->crontab->add_job('0 0 * * *', 'cli_script.php');

This code will execute cli_script.php located in directory you've set
up in config file at 0 minutes 0 hour


Advanced usage
Assuming you have in your $_POST['time'] time when scheduled action should be performed.

$this->load->library('crontab');
$time = $this->crontab->translate_timestamp(strtotime($this->input->post('time')), 's i G * *');
$this->crontab->add_job($time, 'cli_script.php');


If you want to perform an action every day after user submit a data:

$this->load->library('crontab');
$time = $this->crontab->translate_timestamp(time(), 's i G * *');
$this->crontab->add_job($time, 'cli_script.php');

crontab's People

Contributors

biozshock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crontab's Issues

Why the library doesn't load in a controller?

Hello.
I've a problem with crontab library. If I try the library to loading and using it in principal controller, it works perfectly, but not if I try it in another controller which receives Ajax requests. Do you know why?

Edit: The problem is in the load of the library: $this->load->library('crontab');
If the library is loaded (I try in contructor, in index() function or in another function) the Ajax requests don't be done

Thanks.

How use the library to execute php files in /application folder?

Hello.
I have problems to use the library. If the configuration of "cli_path" in config/crontab.php is done to execute files (with cronjob) outside /application folder. Files are executed correctly but not if the config is done to execute inside /application folder. I need to execute files inside because they use some controller functions.

Can you help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.