I'm interested in what the code (command line and php) would look like where every minute or hour you take inventory of the number of item sales obtained from a mysql database and do some action based on that. I'm using CodeIgniter for PHP and I'll call my controller "cronControl".
Here's what I have so far for the command line part (including directory):
:htdocs TimPeterson$ * * * * * php index.php cronControl countSales
Here's the cronControl php part:
class CronControl extends CI_Controller {
function countSales(){
$count=$this->db->query("SELECT stuff");
//do->stuff->based on $count;
$count="i counted 137 items";
file_put_contents("mylogfile.txt", $count);
}
}
When I type the above command into shell I get:
-bash: 404.php: command not found
It looks like it is evaluating all the php scripts in my root directory (where my 404.php page is) and not just the cronControl/countSales controller. Please note that this shell command works and prints $count to mylogfile.txt if you leave out the 5 asterisks.
Any thoughts on what's going on?
problem solved!!!: the key is when typing the command in the crontab file to include the asterisks, but in the shell to NOT include the asterisks
so in crontab -e:
* * * * * /usr/bin/php /applications/xampp/htdocs/index.php cronControl countSales
whereas in htdocs $
/usr/bin/php /applications/xampp/htdocs/index.php cronControl countSales