LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-09-2001, 01:33 AM   #1
Undead
LQ Newbie
 
Registered: Aug 2001
Distribution: RH 7.1
Posts: 5

Rep: Reputation: 0
Timed Execution


How can I get a php script to run every hour or every day? I am using Linux 7.1

Can I even get a php script to run without calling it thro apache? I have no clue as you can probably see :/
 
Old 09-09-2001, 05:19 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Cron would seem to be the obvious way, but i don't know anythign about PHP
 
Old 09-11-2001, 08:56 PM   #3
sykkn
Member
 
Registered: Apr 2001
Location: Texas
Distribution: Mandrake 8.0, RedHat 7.1
Posts: 48

Rep: Reputation: 15
You can run php scripts without apache. You can just run the script at the shell prompt. You may want to run it with the '-q' option to remove the html header tags.

# php -q script.php

The below script to print "hello world" will look different depending on whether or not you use this option.

PHP Code:
<? 
print "Hello World! \n" 
?>
This script without the '-q' option would produce the following output:

================================

X-Powered-By: PHP/4.0.5
Content-type: text/html

Hello World!

================================

While, using the '-q' option would only produce this:

================================

Hello World!

================================
 
Old 09-12-2001, 09:35 AM   #4
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
Just a note - Sykkn's post assumes you have installed PHP as a stand alone CGI interpretter (sp?)... I've never seen this done, so its probably not the case with your setup. Also, unless this is the case then you won't be able to call the PHP script from cron directly - you'd need to use something like mget or Pavuk to run regularly and access the URL to get the script executed.

It sounds to me like you want a Perl script instead...

cheers

Jamie...
 
Old 09-12-2001, 03:16 PM   #5
Undead
LQ Newbie
 
Registered: Aug 2001
Distribution: RH 7.1
Posts: 5

Original Poster
Rep: Reputation: 0
how could I get a cgi script run thro cron?
 
Old 09-13-2001, 02:57 AM   #6
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
You would just need to call it like any other program in cron... its effectively just a shell script... If you want to pass parameters to it then you may want to put those parameters in a text file and call the script with something like myCGIScript.cgi < myTextFile that way your parameters will be passed to the script on STDIN - the same way the HTTP 'get' method goes about it.

HTH

Jamie...
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Timed suspend.. Alex_jacobson Slackware 3 04-15-2005 09:23 PM
How to tell where the execution is going on right now? bahadur Programming 7 04-03-2005 03:42 AM
connection timed out. moby Linux - Networking 0 10-13-2004 07:45 AM
Timed execution of a function arvind_tyche Programming 1 05-07-2004 08:25 AM
no host, timed out awd86 Linux - Networking 3 11-05-2003 06:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration