By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Run PHP file as cronjob

P: n/a
Hello,

I have a PHP file that reads another PHP file and writes it as a static
HTML page. I'd like to run the first PHP file as a cronjob (so that the
static HTML page is updated once an hour).

I'm familiar with scheduling a cronjob and all the PHP is working
perfectly. I don't know how to get cron to "run" a PHP file however.
Any advice would be greatly appreciated.

Jun 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Mossum wrote:
Hello,

I have a PHP file that reads another PHP file and writes it as a static
HTML page. I'd like to run the first PHP file as a cronjob (so that the
static HTML page is updated once an hour).

I'm familiar with scheduling a cronjob and all the PHP is working
perfectly. I don't know how to get cron to "run" a PHP file however.
Any advice would be greatly appreciated.


Alt 1:
If you have the CLI version of PHP installed, simply write
@hourly /path/to/php/interpreter/php /path/to/php/script.php

Alt 2:
Use wget/lynx/curl etc etc to fetch the file via the webserver. You can
then either echo the content out, and have wget/...etc save it to
wherever you want it, or you can still do this in the PHP-script, and
don't return any content to wget

--
Tommy Gildseth
http://design.twobarks.com/
Jun 21 '06 #2

P: n/a

Tommy,

Thank you! I tried scheduling a cron job with fetch -- and it works.

Jun 21 '06 #3

P: n/a
On Wed, 21 Jun 2006 12:51:08 -0700, Mossum wrote:
I'm familiar with scheduling a cronjob and all the PHP is working
perfectly. I don't know how to get cron to "run" a PHP file however.
Any advice would be greatly appreciated.


Beginning it with
#!/usr/bin/php or #!/usr/local/bin/php would be a good start. Also,
change protection to 755, so that httpd process can open it.

--
http://www.mgogala.com

Jun 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.