I am trying to run a php script without cron and succeeded but doesn't work as I expected. I want the script to make a backup every 50 minutes, but it doesn't do that, it makes them continuous. This is what I tried:
cron.php
<?php
$interval=50; //minutes
set_time_limit(0);
ignore_user_abort(true);
while (true)
{
    $now=time();
    include("backup.php");
    sleep($interval*60-(time()-$now));
}
?>
backup.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$username = "user";
$password = "pass";
$hostname = "dbs";
$dbname   = "dbs_name";
// if mysqldump is on the system path you do not need to specify the full path
// simply use "mysqldump --add-drop-table ..." in this case
$dumpfname = $dbname . "_" . date("Y-m-d_H-i-s").".sql";
$command = "mysqldump --add-drop-table --host=$hostname --user=$username ";
if ($password)
$command.= "--password=". $password ." ";
$command.= $dbname;
$command.= " > " . $dumpfname;
system($command);
// zip the dump file
$zipfname = $dbname . "_" . date("Y-m-d_H-i-s").".zip";
$zip = new ZipArchive();
if($zip->open($zipfname,ZIPARCHIVE::CREATE))
{
    $zip->addFile($dumpfname,$dumpfname);
    $zip->close();
}
// read zip file and send it to standard output
if (file_exists($zipfname)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($zipfname));
    flush();
    //readfile($zipfname);
    //exit;
}
?>
 
     
    