1
votes

HI I want to implement a cron job in my Zendframe work. I have checked its phpinfo then I got Server API is CGI/FastCGI and SERVER_SOFTWARE is Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8m DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635

So i realized that my project is running at CGI

I am new to this Cron job. also i don't know shell and related words. So please give me any good tutorial to implement crone job

Thanks in advance

2

2 Answers

1
votes

Check out this tutorials on crons

http://clickmojo.com/code/cron-tutorial.html

http://www.htmlcenter.com/blog/running-php-scripts-with-cron/

What you need first is to implement the logic of the task in your script and then just run the script with crontab. Use

crontab -e 

to edit your crontab file.

Talking about zend, you can

1)put the required code in one of you controllers

or

2) -create a folder "crons" in you project

-put a new php script in this folder

-put a cron job in your crontab file to run your script

your crontab file may look like this

30 18 * * * php /path-to-your-cron/cron.php
1
votes

Just write your script like you normally do. And then add it to the crontab by running the crontab command.

Example

$ crontab -e

*    *    *    *    *      command to be executed
┬    ┬    ┬    ┬    ┬
│    │    │    │    │
│    │    │    │    └───── day of week (0 - 6) (Sunday=0)
│    │    │    └────────── month (1 - 12)
│    │    └─────────────── day of month (1 - 31)
│    └──────────────────── hour (0 - 23)
└───────────────────────── min (0 - 59)

So for you this could be

0 */1 * * *  /home/user/foo/cron-script.php

This will run the script every hour.