PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 21st, 2000, 12:36 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

Hi,

How can i do cron job for executing my PHP script once in every day...

i want to remind the people about their birthday in reminder.php.

that would be one week before thier birthday and one day before their birthday...

can i perform this action with cron job??,


Can you tell me the syntax???.








------------------
shiju

Reply With Quote
  #2  
Old February 25th, 2000, 06:22 PM
kourou kourou is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 1999
Location: London UK
Posts: 7 kourou User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the following is adapted from the script delivered with phpAds <http://www.phpwizard.net>. theoriginal used fetch instead of lynx which i believe is only available on FreeBSD or something...

59 23 * * * lynx -dump http://ads.ourdomain.net/mail.php3>>/var/log/messages

an alternative would be to use cgi php (which can be used at the same time as mod_php) in a script with #!/bin/php
(or whatever your path is) at the top like a perl cgi script

Reply With Quote
  #3  
Old June 1st, 2000, 11:14 AM
jochum jochum is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: In nederland
Posts: 41 jochum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 2 sec
Reputation Power: 14
Use this perlscript it runs your php3 code..
activate the perlscript with cron.

#!/usr/bin/perl

my $url = shift;
$url = URI::URL::url($url, "http://www.??.??/cron.php3")->abs;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use MIME::Base64;
my $ua = new LWP::UserAgent;
my $request = new HTTP::Request('GET', $url);
my $res = $ua->request($request);
my $result = ($res->is_success)?$res->content:$res->error_as_HTML;
$result = $1 if $result =~ /<BODY.*?>(.*?)</BODY>/si;
$result =~ s/(<IMG.*?SRC="?)(.*?)([" >])/$1.URI::URL::url($2, $url)->abs.$3/gies;
$result =~ s/(<A.*?HREF="?)(.*?)([" >])/$1.URI::URL::url($2, $url)->abs.$3/gies;


[This message has been edited by jochum (edited June 01, 2000).]

Reply With Quote
  #4  
Old June 2nd, 2000, 05:50 PM
moderator
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
This is how we do it here at ngenuity.
Simply compile PHP as a CGI binary and move it to somewhere convenient, such as /usr/bin/.

Then make the first line of the script
#!/usr/bin/php

this tells the OS what program to process the script with, exacly like the famous
#!/usr/bin/perl
used in perl or the less famous
#!/bin/sh
used for most shell scripts.

Then in the cron tab, you can call the script directly i.e. /data/servers/www.devshed.com/scripts/script.php

This works great, especially if it is a sensitive script... you can keep it out of your web root and accessable only to your crond.

Do be sure to keep all the script within <?php ?> tags.

#!/usr/bin/php
<?
...script here...
?>

Anything print()ed, or echo()ed will be output to stdout, as will anything not in <?php ?>.

Reply With Quote
  #5  
Old June 3rd, 2000, 01:09 PM
smarques smarques is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 2 smarques User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
One more question: what if I don't have access to cron on my unix system (I am using a host).
Is there a way to call lynx from a php page?
And then not wait for the process to finish?

Thanks so much
Sergio

Reply With Quote
  #6  
Old June 3rd, 2000, 02:28 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
>>what if I don't have access to cron on my unix system
Can you run cron locally then? Or another system with cron access remotely to your unix system?


Reply With Quote
  #7  
Old June 14th, 2000, 09:44 PM
rik rik is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Posts: 10 rik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>>what if I don't have access to cron on my unix system <<

You shouldn't have access to run cron. You need to run crontab to configure cron.

Reply With Quote
  #8  
Old June 15th, 2000, 05:16 PM
Robman Robman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: SLC, UT, USA
Posts: 47 Robman User rank is Private First Class (20 - 50 Reputation Level)Robman User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Just goes to show you...learn something new everyday.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > How can i do cron job for executing my PHP file?Help me!!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap