PHP & Cron - Basic Questions 4 Newbie
Posted: Wed Aug 10, 2011 2:36 pm
So I've been learning PHP for about a year now. I've built several small and a few bigger applications. Now I'm on an applications which requires cron. Suffice it to say, it's kicking my arse.
For those of you who are experienced, perhaps you can help answer some of my questions...
1) When I run the script directly by calling it in the browser, there are not any errors and it completes in about 2 min 40 seconds. Yet when I call it in cron, it can take as much as an hour to complete, and sometimes it hangs.
2) I've been using two different commands: /usr/bin/php -q /path/to/script and wget -q http :// direct path to script .php . Is there a better way to do this?
3) I've duplicated the script into different filenames, such as fileA.php, and fileB.php. If I want to do twice the work, would it make sense to cron fileA.php and cron fileB.php?
4) Am I correct in assuming that cron will run my php script the same way that a web browser would?
Thanks for your help. It's much appreciated!
M.
For those of you who are experienced, perhaps you can help answer some of my questions...
1) When I run the script directly by calling it in the browser, there are not any errors and it completes in about 2 min 40 seconds. Yet when I call it in cron, it can take as much as an hour to complete, and sometimes it hangs.
2) I've been using two different commands: /usr/bin/php -q /path/to/script and wget -q http :// direct path to script .php . Is there a better way to do this?
3) I've duplicated the script into different filenames, such as fileA.php, and fileB.php. If I want to do twice the work, would it make sense to cron fileA.php and cron fileB.php?
4) Am I correct in assuming that cron will run my php script the same way that a web browser would?
Thanks for your help. It's much appreciated!
M.