Forum Moderators: coopster

Message Too Old, No Replies

Help me in PHP Cron Jobs

         

adrevol

6:00 pm on May 29, 2008 (gmt 0)

10+ Year Member



Hello Friends,
Today for the first time i heard about cron job, when i google it i came to know that it acts as a schedular usually sending mails every day at perticular time.

and it said

30 23 * * * /home/username/www/cgi-bin/members.cgi

when i create a cron job with above line, this members.cgi will execute everyday at 11:30..

Now my doubt is like members.cgi can i run myfile.php also ?

in which i will be sending email to all my members. lets say myfile.php is at http://www.example.com/pqrs/abc/myfile.php

How can i schdule this myfile.php as a cron job

30 23 * * * /home/username/www/pqrs/abc/myfile.php

will it serve my purpose ?

please let me know

[edited by: dreamcatcher at 6:13 pm (utc) on May 29, 2008]
[edit reason] use example.com. Thanks. [/edit]

eelixduppy

6:07 pm on May 29, 2008 (gmt 0)



Hello and Welcome to WebmasterWorld!

You need to use php interpreter as follows:


30 23 * * * /path/to/php -f /home/username/www/pqrs/abc/myfile.php

adrevol

6:20 pm on May 29, 2008 (gmt 0)

10+ Year Member



thanks for the information,

sorry to ask this .. in my webserver, how can i know my php source path

and what is this -f and what it will do .. in case i want to stop this cron .. what is the step i have to take..

thanks in advance

eelixduppy

8:01 pm on May 29, 2008 (gmt 0)



>> how can i know my php source path

You have to find the directory where it is. Try /usr/bin

>> what is this -f and what it will do

It specifies that you running a file, where the filename comes after it.

>> in case i want to stop this cron

You can remove that line from your crontab file, or you can comment it out with the pound symbol (#).

It would look like the following, then:


#30 23 * * * /usr/bin/php -f /home/username/www/pqrs/abc/myfile.php #commented out

coopster

10:58 am on Jun 1, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> how can i know my php source path

You have to find the directory where it is.

You can use "whereis" or "locate"

bashprompt> whereis php