-2

i trying to create cron using php i tried lot of example on my hosting i dont have cpanel or cli. i tried lot of code. i am new in php. i tried this example

0 * * * * /usr/local/bin/php path/of/php/file

or

<?/** suppose we have 1 hour and 1 minute inteval 01:01 */

$interval_source = "01:01";
$time_now = strtotime( "now" ) / 60;
$interval = substr($interval_source,0,2) * 60 + substr($interval_source,3,2);


if( $time_now % $interval == 0){
/** do cronjob */
}

i dont know where i run this code file pls help me

1 Answers1

0

Use crontab of linux.

sudo crontab -e

Run your cron jobs as

/5 * * * *  /path/to/php /var/www/html/yourCodeFile.php

This job runs after every 5 minutes.

yourCodeFile.php must have the logic of whatever you want to get done.

For more details kindly read this one: How to create cron job using PHP?

Community
  • 1
  • 1
Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78