Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 21st, 2003, 02:00 AM
Registered User
Join Date: Oct 2003
Location: , , .
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.
Reply With Quote
  #2 (permalink)  
Old October 21st, 2003, 07:30 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts

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.

P.S. Full instructions can be had at the usual source ;)
Reply With Quote
  #3 (permalink)  
Old October 21st, 2003, 04:58 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts

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,

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 07:02 PM.

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