my coding had regarding crontab in linux and php, what I want to do is my cronjob datetime is * * * * *, that mean it every minute also will checking the result, so once my result had check complete , it will insert to database, but now my results are keep inserting to database, so how to everyday insert only one record in database with the cronjob run every minute or how to stop keep inserting result to database?
thank you hope you guys reply me soonest
Do the following:
You have to check if you have already inserted the date. Assuming your table is Table
and column that stores date is date
as timestamp
$sql = "select * from Tablewhere DATE(`date`) = CURRENT_DATE()";
$result = mysql_query($sql);
if (mysql_num_rows($result)>0){
//you already have inserted current date, handle this as you need
}
else{
//current date have not beed inserted, insert it as usual
}
This code does not check for sql errors and does not use prepared statments , but it's simple and provides you with a good idea to start.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.