Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 21st, 2003, 02:00 AM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cron job for a php-file

I have searched, but not yet found a way to run a php-file in my crontab. PHP is compiled with Apache on a FreeBsd machine.

If you can tell me how to run a php-file from my command prompt, that's fine too.
 
Old October 21st, 2003, 07:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To run PHP at the tcsh prompt, you must have the CLI version of PHP (4.3.0 onwards). You can determine this by typing "php -v" - e.g., I get:

moon# php -v
PHP 4.3.1 (cli) (built: May 28 2003 01:33:36)
Copyright (c) 1997-2002 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies


Then just run your script. The syntax is thus:

moon# php my_script.php

Works for me. FYI, I'm on a Toshiba Satellite laptop running FreeBSD 5.1 Release.

HTH
Dan
P.S. Full instructions can be had at the usual source ;)
http://www.php.net/manual/en/features.commandline.php
 
Old October 21st, 2003, 04:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you don't have the authority to install PHP's commandline interpreter, and are stuck with it installed as an apache module, then put your script somewhere it can be accessed via the web, and use wget or curl to fetch that web page. Apache will run your PHP script to service the HTTP request.

Also, PHP has a "-q" option for running things on the commandline that supress the default HTTP header output. This is usually just "Content-Type: text/html" and "X-Powered-By: PHP/<version>".


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron Job mani_he Linux 4 December 16th, 2010 07:02 AM
Windows cron job hsauer VB How-To 0 August 9th, 2006 11:40 AM
Cron Job Error - Need Help jkirkpatrick Linux 2 August 5th, 2005 05:51 AM
Cron job error ganesh15 Linux 1 October 22nd, 2003 04:04 AM
Cron Job... Urgent ganesh15 Linux 2 September 19th, 2003 01:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.