tag:blogger.com,1999:blog-8993867651193907565.post7828078416744277313..comments2023-05-29T06:56:18.941-07:00Comments on Think Different: Running PHP Scripts with CronDhiraj Patrahttp://www.blogger.com/profile/15178095650559397430noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-8993867651193907565.post-21817053062011694182008-10-02T04:49:00.000-07:002008-10-02T04:49:00.000-07:00Another thing - if your scrpit has any relative-re...Another thing - if your scrpit has any relative-reference <B>include</B>s <BR/>e.g., <BR/><BR/>include('../testdir/dbconnect.inc');<BR/><BR/> then you might as well forget php under cron, because you're going to have to go into every cron'ed script and replace all relative references with absolute references.<BR/><BR/>PHP does cron (or vice versa) SO badly that I decided instead to use curl and -o /dev/null (as well as /dev/null 2>&1 to suppress cron e-mails). <BR/><BR/>It makes for an ugly and inefficient crontab, but unless you're prepared to sticky-tape a change to include-path into every script (more overhead) you're on a hiding to nothing.<BR/><BR/>Cheers<BR/><BR/><BR/>GT<BR/>France<BR/><A HREF="http://marketrant.blogspot.com" REL="nofollow"><B>GT's markekt Rant</B></A>Kratoklasteshttps://www.blogger.com/profile/08656600074436057305noreply@blogger.comtag:blogger.com,1999:blog-8993867651193907565.post-11994502059657934702008-08-05T09:08:00.000-07:002008-08-05T09:08:00.000-07:00A good post but a couple of points I would make.Fi...A good post but a couple of points I would make.<BR/><BR/>Firstly, if you have a Shebang (and are running on Linux) and the file mode is executable there is no requirement to pass the script to the php binary. <BR/><BR/>Secondly, if you are using the binary in cron, you should always pass the full path. e.g.<BR/><BR/>1 * * * * /usr/bin/php /path/to/script.php<BR/><BR/>as you cannot guarantee that cron will instantiate the PATH environment variable.<BR/><BR/>Finally, if using the Apache module you can also use wget -q --delete-after http://url/to/script.php and pipe the output to /dev/null ( > /dev/null 2>&1) or curl and pipe the stdout to dev null.<BR/><BR/>RobAnonymoushttps://www.blogger.com/profile/07392341788575597725noreply@blogger.com