|
-
Jul 2nd, 2009, 03:26 AM
#1
Thread Starter
Fanatic Member
run php code after each 10 hours
hi
i have a php page and i want to run it after every 10 hours automatically. How this can be achieved pls help
-
Jul 2nd, 2009, 04:43 AM
#2
Re: run php code after each 10 hours
if you're using a unix based server, look up how cron jobs work, or ask your host. if you're doing it locally or just on a windows server, look up how scheduled tasks work.
-
Jul 2nd, 2009, 04:46 AM
#3
Thread Starter
Fanatic Member
Re: run php code after each 10 hours
 Originally Posted by kows
if you're using a unix based server, look up how cron jobs work, or ask your host. if you're doing it locally or just on a windows server, look up how scheduled tasks work.
hi i have set up this cron job and also but i have not yet received any email from my e_mail.php
Code:
* * * * * /usr/bin/php -q /home/user/public_html/e_mail.php
also i add this cron
and i received emails from my second cron. why first cron is not working?
-
Jul 2nd, 2009, 03:37 PM
#4
Thread Starter
Fanatic Member
Re: run php code after each 10 hours
hi
i can run my second page now with the cron job, with this command
Code:
* * * * * /usr/bin/php -q /home/user/public_html/e_mail.php
but i want to use header() function in in my php page which is added to cron job but i dont get it working
Code:
<?
header("location : http://remote.com/page.asp");
?>
-
Jul 2nd, 2009, 07:10 PM
#5
Re: run php code after each 10 hours
you can't use a header like that because the PHP binary is running the script, not a browser.
-
Jul 3rd, 2009, 12:18 AM
#6
Thread Starter
Fanatic Member
Re: run php code after each 10 hours
 Originally Posted by kows
you can't use a header like that because the PHP binary is running the script, not a browser.
So please suggest me any other option
i have tried
the code is in my php page which is added in cron job is
Code:
<?php
$contents = file_get_contents("http://remotesite.com/remotepage.php");
?>
and the page on the remote site contain this code
Code:
<?php
$f=fopen("remotepage.php","a")
fwrite($f,"text added<br>");
fclose($f);
mail("[email protected]","Subject here","the body");
?>
it works fine and when i see this page
Code:
http://remotesite.com/remotepage.php
on my browser i see that new text is added into this page. But i do not get the email.
but when i use this code in remotepage.php i get the email from the server where the original cron job page is uploaded.
Code:
<?php
$f=fopen("remotepage.php","a")
fwrite($f,"text added<br>");
fclose($f);
$c = file_get_contents("http://originalsite.com/emailpage.php")
?>
and emailpage.php contain this code
and i get the email this way.
do you think that this will solve the issue?
Last edited by chunk; Jul 3rd, 2009 at 12:22 AM.
-
Jul 3rd, 2009, 01:36 AM
#7
Re: run php code after each 10 hours
@ Chunk,
Is there any reason why you are using two php files? Why not combine the two?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jul 3rd, 2009, 02:38 AM
#8
Thread Starter
Fanatic Member
Re: run php code after each 10 hours
 Originally Posted by Nightwalker83
@ Chunk,
Is there any reason why you are using two php files? Why not combine the two?
yes
i have change the URL to ASPX page that is hosted on another server
Code:
<?php
$contents = file_get_contents("http://remotesite.com/remotepage.aspx");
?>
so i tested it with the php pages on different servers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|