I just created a cron job in cpanel, but it's not working. I just want to get something straight, because maybe I am doing it wrong... If I go and create a file which creates a new file, ie: $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "Bobby Bopper\n"; fwrite($fh, $stringData); $stringData = "Tracy Tanner\n"; fwrite($fh, $stringData); fclose($fh); Code (markup): ..and then run it in my browser, it creates a file called testFile.txt. *All good so far* I thought that all I had to do to add a cron in cpanel was to set the time for the cron (ie: every 5 minutes for testing purposes, but once I have it all running, I'll change it to once every 24 hours)... and then just add the location of the file I want to run. ie: /home/mysite/public_html/myfile.php ...I did all that, but it's not working. What's the deal? Am I doing it wrong? Am I supposed to enter some sort of command, as per step 4 of these instructions (instead of just the file loction)? http://www.siteground.com/tutorials/cpanel/cron_jobs.htm
You probably need the php command. Try this: php -q /home/serverpath/script/file.php If that doesn't work (which it might not if PHP is not installed as CGI), then you should be able to do this instead, which just calls it as if it were through a browser: wget -q [FULL URL TO YOUR PHP PAGE]
PHP sends output to the screen. In your case there isn't any output, but -q will kill any echo command or print command output.