MadDawgX Posted January 8, 2008 Share Posted January 8, 2008 Hey, How can I execute some PHP/MYSQL on an exact time basis (every 10 minutes) - Thanks Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/ Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 You'll have to use a cron job for this. Know about them? Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433886 Share on other sites More sharing options...
MadDawgX Posted January 8, 2008 Author Share Posted January 8, 2008 Yeah that's what I figured, but wasn't sure. And no, I know absolutely nothing about them, never used them before... is it simple for something like this? Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433895 Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 It's pretty simple once you get the UNIX syntax. Should be easy if you have worked with UNIX/Linux. I have a link that I refer to but I bet someone else around here have better ones. http://www.kalab.com/freeware/cron/cron.htm Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433902 Share on other sites More sharing options...
revraz Posted January 8, 2008 Share Posted January 8, 2008 May be helpful http://www.phpfreaks.com/forums/index.php/topic,175298.0.html Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433903 Share on other sites More sharing options...
MadDawgX Posted January 8, 2008 Author Share Posted January 8, 2008 Ok, so say I have a script titled 'update.php' in the index of my website. When I goto my cpanel, I have an item called Cron Jobs which I then get to a page where I specify the command. So is this what I put? MINUTE HOUR DAY MONTH WEEKDAY COMMAND 10 * * * * update.php Or do I have to specify an exact path? Im on a shared server through Bihira.com btw Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433912 Share on other sites More sharing options...
Ken2k7 Posted January 8, 2008 Share Posted January 8, 2008 Try putting the full path. It doesn't hurt. Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433913 Share on other sites More sharing options...
revraz Posted January 8, 2008 Share Posted January 8, 2008 You may have to go as far as putting in the server path, not the url. Check with your host. Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433916 Share on other sites More sharing options...
rhodesa Posted January 8, 2008 Share Posted January 8, 2008 i wouldn't count on update.php running on it's own. you should specify the full path the php and the full path to your file. if this is on your hosting companies server, i would check their FAQ section, as it is most likely there. Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433920 Share on other sites More sharing options...
MadDawgX Posted January 8, 2008 Author Share Posted January 8, 2008 Ok, so I checked with my host I got an answer; here's the command: php /home/ufnwvwju/public_html/temp/cron_shares.php But it doesn't seem to be working? Here is cron_shares.php: // ******************************* // INITIALIZE // ******************************* session_start(); mysql_connect("localhost", "****", "****") or die(mysql_error()); mysql_select_db("ufnwvwju_sb") or die(mysql_error()); // ******************************* // CRON JOB // ******************************* $g_stats = mysql_query("SELECT * FROM sb_stats"); $stats_shares = mysql_result($g_stats,0,'stats_shares'); $stats_mbal = mysql_result($g_stats,0,'stats_mbal'); $share_value = number_format($stats_mbal / $stats_shares,4); $i_share = mysql_query("INSERT INTO sb_shares (shares_value) VALUES('$share_value')"); But the database is turning up empty? Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433954 Share on other sites More sharing options...
revraz Posted January 8, 2008 Share Posted January 8, 2008 Did you read the link I posted? Make sure you check out the link in the 2nd reply Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433957 Share on other sites More sharing options...
trq Posted January 8, 2008 Share Posted January 8, 2008 You will likely need the full path to the php executable as well. /usr/bin/php /home/ufnwvwju/public_html/temp/cron_shares.php Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433960 Share on other sites More sharing options...
MadDawgX Posted January 8, 2008 Author Share Posted January 8, 2008 Ok, I updated it and still no results Here's where I got the info from my host: http://www.bihira.com/vbulletin/showthread.php?t=323&highlight=Cron Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433976 Share on other sites More sharing options...
trq Posted January 8, 2008 Share Posted January 8, 2008 Does the script work if called via the server (ie browser)? There is absolutely no error handling/checking. Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-433999 Share on other sites More sharing options...
awpti Posted January 8, 2008 Share Posted January 8, 2008 Actual cron would be: */10 * * * * /my/command 10 * * * * just runs it on the 10th minute of every hour. 1:10.. 2:10 3:10 4:10 Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-434046 Share on other sites More sharing options...
MadDawgX Posted January 8, 2008 Author Share Posted January 8, 2008 Ahh it's working now, I had a typo with my username in the path And thanks awpti for that correction Solved! Quote Link to comment https://forums.phpfreaks.com/topic/85078-solved-execute-php-every-10-minutes/#findComment-434060 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.