I'm using my cpanel to lunch a cron action thats open a file a write Hello every minute.
But that task is not working.
This is my code :
<?php
header("Location: http://www.google.com");
$handle = fopen("passes.txt", "a");
fwrite($handle, "Hello");
fwrite($handle, "\n");
fclose($handle);
exit;
?>
When I try to lunch the script directly in my browser it's working fine, but the cron job isn't working at all.
I've used this command to launch the script :
* * * * * * http://www.mysite.com/myfile/write.php
.
EDIT:
All your commands
are not working for me.
I'm usin开发者_StackOverflowg Cron tasks
in my cpanel
.
to run this cron every minute you have to use something like this:
*/1 * * * * wget http://www.mysite.com/myfile/write.php
or
* * * * * wget http://www.mysite.com/myfile/write.php
you can do this in 2 ways
if you have wget on your system:
1: * * * * * * wget -O /dev/null http://www.mysite.com/myfile/write.php
else:
2: * * * * * * /path/to/your/php/bin/php /path/to/myfile/write.php
You need to send the request via wget, to simulate a browser request:
* * * * * * wget -q http://www.mysite.com/myfile/write.php
Your command is not a command you could run in a shell. It should either be
php /var/www/yoursitePath/yourFile/write.php
or
curl http://www.mysite.com/myfile/write.php
I don't know what the header
should do for you in a script though, can't see that having any effect whatsoever when called like this
精彩评论