How to stop a cron job after the task is completed?
The job of cron to transfer a set no. of email id's from 1 sql table to another using given specific restrictions. The task executes but does not stop. It re-runs to add duplicate values the table but the limit setting in the php file is not working.
I have posted the code here......
<?php
$con = mysql_connect("","","") or die(mysql_error());
mysql_select_db("email_vijaya",$con) or die(mysql_error());
session_start();
?>
<?php $ref = mysql_query("SELECT * FROM Email_Transford_Count WHERE status = '1'"); ?>
<?php if(mysql_num_rows($ref) == '0') { ?>
<?php } else { ?>
<?php while($yr = mysql_fetch_array($ref)) { ?>
<?php $actual_Count = $yr['Actual_Count']; ?>
<?php $Uploaded_ctual = $yr['Rest_Count']; ?>
<?php $rest = ($actual_Count)*1-($Uploaded_ctual)*1; ?>
<?php $re = $yr['Rest_Count']; ?>
<?php if($actual_Count >= $Uploaded_ctual) { ?>
<?php $country = mysql_query("select Email_IDs from eData where City = '".$yr['city']."' AND category = '".$yr['category']."' limit $re"); ?>
<div class="email_css">
<?php while($u = mysql_fetch_assoc($country)) { ?>
<?php mysql_query("UPDATE Email_Transford_Count SET Rest_Count = Rest_Count+1 WHERE User_id = '".$yr['User_id']."' AND category = '".$yr['category']."' AND status = '1' "); ?>
<?php if($actual_Count >= $Uploaded_ctual) { ?>
<?php mysql_query("INSERT INTO eData_ClientTransfered VALUES ('','".$yr['User_id']."','".$u['Email_IDs']."','".$yr['category']."','1')"); ?>
<?php } ?>
<?php } ?>
<?php } else { ?>
<?php mysql_query("UPDATE Email_Transford_Count SET status = '2' WHERE User_id = '".$yr['User_id']."' AND status = '1'"); ?>
<?php } ?>
<?php } ?>
<?php } ?>