Cron job related question
Posted by: sharpdebate
Posted on: 2006-05-26 02:40:00
Well guys
I'm trying to set up a cron job. After some googling and having gone thro' DH's wiki, here's what I'm having problem.
DH wiki : To execute a PHP script using crontabs, you must add this line to the top of the PHP script you want to execute for it to work: #!/usr/local/bin/php -q
Now say I want my file cron.php to run every five minutes. This means I should add #!/usr/local/bin/php -q at the top of cron.php first, am I right? Then, where it should be exactly, even before the the beginning <?php or after? Like
#!/usr/local/bin/php -q
<?php
// rest goes here
or
<?php
#!/usr/local/bin/php -q
//rest goes here
They also tells, alternatively, I can set up the cron like:
*/5 * * * * /dh/cgi-system/php.cgi /home/myuser/mydomain.com/cron.php
Since they have used the term alternatively, I can use any of these two, logically. But, where I am telling when the cron to be executed in the first example? If I go for the second example, they tells that I should save the line in a text file and upload it. Now, where should I upload it? In the same directory as my domain name or before that?
I am also confused between
*/5 * * * * /dh/cgi-system/php.cgi /home/myuser/mydomain.com/cron.php
and
*/5 * * * * wget -q -O /dev/null http://mydomain.com/cron.php
Can anyone help?
Thanks.
Web's ultimate debate center - www.SharpDebate.com