Yii Framework Forum: [Extension] Crontab - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Extension] Crontab Rate Topic: -----

#1 User is offline   yiimann 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 19-December 09

Posted 01 August 2010 - 10:26 AM

I just created a extension to manage system cron jobs with Yii that can also be used to run Application console commands.

http://www.yiiframew...on/yii-crontab/
0

#2 User is offline   yiimann 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 19-December 09

Posted 01 August 2010 - 05:26 PM

just release version 0.3

Previous jobs are now retrieve from crontab file for further modifications and stuff...
0

#3 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,013
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 02 August 2010 - 01:47 AM

Looks nice. :) Two notes:

- You should better use __construct() as constructor name.
- Maybe add a comment, that the crontab file must be writeable for the webserver if you want to manage jobs through a webinterface. This should be a well considered decision, as it can open up a huge security hole.
0

#4 User is offline   yiimann 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 19-December 09

Posted 02 August 2010 - 02:56 PM

Crontab file access is based upon user permission. If user is wwwuser1, the extension creates a crontab file(typically, this is just a normal text file) for that user in the directory of this extension and then use 'crontab file' unix command to load the jobs in system crontab for that user. I guess there shouldn't be any security holes.
0

#5 User is offline   StErMi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 259
  • Joined: 30-March 09

Posted 31 August 2010 - 03:04 AM

I'm going to try to use it for my current project :)
0

#6 User is offline   StErMi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 259
  • Joined: 30-March 09

Posted 31 August 2010 - 04:26 AM

Can you please add other documentation?

I've extracted everything under the folder extensions, but when you try to do

$cron = new Crontab('my_crontab'); // my_crontab file will store all added jobs


It will exit with this error:
PHP Error
Descrizione

include(Crontab.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
File Sorgente

C:\xampp\htdocs\yii-1.1.3\framework\YiiBase.php(338)


Can you please provide further informations like what to put into yii config?
0

#7 User is offline   bigardusklei 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 04-January 11
  • Location:Asturias, Spain

Posted 01 September 2011 - 12:09 PM

Hi!
I have some trouble using your extension... I've posted here http://www.yiiframew...ab-help-please/
Can you help me?
Thanks in advance!
Cheers!!!
0

#8 User is offline   Trong Tran 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 26-September 12

Posted 26 September 2012 - 09:59 PM

In the usage guide document (http://www.yiiframew...ion/yii-crontab) has code lines



Usage

See the following code example:

// Usage with ApplicationConsole and normal jobs
 
    $cron = new Crontab('my_crontab'); // my_crontab file will store all added jobs
 
    $jobs_obj = $cron->getJobs(); // previous jobs saved in my_crontab
 
    foreach($jobs_obj as $job)
        echo $job->getCommand();
 
    $cron->eraseJobs(); // erase all previous jobs in my_crontab
 
    // Application console job
    $cron->addApplicationJob('yiicmd', 'test1', array(), '*');
 
    // to change job values:
    $jobs_obj = $cron->getJobs();
    $jobs_obj[0]->setParams(array("'datetime'"));
    $jobs_obj[0]->setCommandName('test');
 
    // <= adds a job with: * * * * * php /home/user/my_project/www/yiicmd.php test 'datetime'
 
    // add an other job
    $job = new CronApplicationJob('yiicmd', 'test', array("'datetime"), '0', '0'); // run every day
    $job->setParams(array("'date'"));
    $cron->add($job);
 
    // <= adds a second job with: 0 0 * * * php /home/user/my_project/www/yiicmd.php test 'date'
 
    // add a regular cron job
    $cron->addJob('/home/user/myprogram.bin', '0', '0', '*', '*', '1'); // run every monday
    $jobs_obj = $cron->getJobs();
    echo $jobs_obj[2]->getCommand();
 
    // <= adds a third job with: 0 0 * * 1 /home/user/myprogram.bin 
 
    $cron->removeJob(2); // removes job with offset 2 (last added here)
 
    $cron->saveCronFile(); // save to my_crontab cronfile
 
    $cron->saveToCrontab(); // adds all my_crontab jobs to system (replacing previous my_crontab jobs)



I don't know where is php file to put these code lines? Please help me

thanks
0

#9 User is offline   phpkunst 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 23-October 12

Posted 21 November 2012 - 05:25 AM

Split function php is deprecated, us preg_split!!

This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users