crons job
config.php
<?php
$servername = "localhost";
$username = "pakpoultrypk_website";
$password = "qhofB132";
$db = "pakpoultrypk_website";
// Create connection
$con = mysqli_connect($servername, $username, $password,$db);
// Check connection
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
mainfile.php
#!/usr/bin/php
Or use this
#!/usr/bin/env php
<?php
require_once('config.php');
$date = date('Y-m-d');
mysqli_query($con,"DELETE FROM broiler WHERE expDate<='$date'");
mysqli_query($con,"DELETE FROM chicksBroiler WHERE expDate<='$date'");
mysqli_query($con,"DELETE FROM chicksDomestic WHERE expDate<='$date'");
mysqli_query($con,"DELETE FROM domesticFarming WHERE expDate<='$date'");
mysqli_query($con,"DELETE FROM eggDomestic WHERE expDate<='$date'");
mysqli_query($con,"DELETE FROM eggLayer WHERE expDate<='$date'");
mysqli_query($con,"DELETE FROM workers WHERE expDate<='$date'");
mysqli_query($con,"DELETE FROM poultryFarm WHERE expDate<='$date'");
?>
path of the file
/home/pakpoultrypk/domains/pakpoultry.com.pk/public_html/crons/deleteExpads.php
for help read this
https://stackoverflow.com/questions/9498298/permission-denied-in-cron-jobs-command
Use php /home/gbtusyll/public_html/run.php
instead to run it as a PHP script instead of a regular shell script.
/usr/local/bin/php
, instead of justphp
. So use/usr/local/bin/php /home/cPaneluser/public_html/yourscript.php
. Some cPanels with shared hosts may have different paths./usr/local/bin
and/usr/bin
are popular paths from root. (Apparently, godaddy uses both, based on case. (1) (2) ) – Siddhant Rimal Apr 23 '17 at 1:20