Cron job in php

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 21
Joined: Thu Apr 12, 2012 8:05 am

Thu Apr 12, 2012 10:53 am

You needto set a cronjob on the server itself. You cannot start a script just by itself.

To get it working without using real cronjobs, you can store in your databse when your cron last runned, and let a user activate it:

Code: Select all

$last_runned = $db->query("SELECT `last_run` FROM `lastrunned` LIMIT 1");
$last_runned = $db->fetch(2);
if( $last_runned['last_run'] + 300 < time() ){
 $db->query("UPDATE `lastrunned` SET `last_run` = ?", array( $time()) );
Something like that.

Post Reply