Page 1 of 1
need your help
Posted: Tue Aug 11, 2009 6:55 am
by krvmanoj
hi i am new to php. i need to run a .php file in my server everyday at a certain time.
it seems that i needed to write a bash script. i have no idea about thes things can anyone help me. tell me how to write a script in the linux server and make the .php file to run daily.
thanks in advance.
waiting eagerly for ur replay.
Re: need your help
Posted: Tue Aug 11, 2009 6:56 am
by jayshields
Make a cron job.
Re: need your help
Posted: Tue Aug 11, 2009 7:16 am
by robnet
You don't necessarily need to write a bash script, you can schedule a php file to be executed in the same way.
the command "crontab -e" opens up an editor to allow you to schedule jobs. Make sure you use this command rather than trying to edit manually..
Here's some info in here about how to format the crontab file:
http://www.adminschoice.com/docs/crontab.htm
And your "command to be executed" would be something like "php < myphpfile.php"
So the whole line in your crontab might look like this:
Code: Select all
0 0 * * * php < /home/username/phpscript/myphp.php
This will run your script at midnight every night. - Tweak the zeros and stars to change the schedule.
Re: need your help
Posted: Tue Aug 11, 2009 12:17 pm
by krvmanoj
i am able to make that file bsc.php to run
php /home/tcemcac/public_html/bsc.php
/home/tcemcac/public_html/bsc.php
php /home/tcemcac/public_html/bsc.php
i used all the three commands. help me
Re: need your help
Posted: Tue Aug 11, 2009 1:31 pm
by aceconcepts
Do you know how to create a cron tab? Do you use PHPMyAdmin or something similar?
Re: need your help
Posted: Tue Aug 11, 2009 1:53 pm
by robnet
Try this:
php < /home/tcemcac/public_html/bsc.php
Make sure you include the "<" sign. This will direct the file into the php executable so it can run.
Re: need your help
Posted: Wed Aug 12, 2009 1:08 am
by krvmanoj
/home/tcemcac/public_html/bsc.php: Permission denied
Re: need your help
Posted: Wed Aug 12, 2009 2:17 am
by robnet
Well at least that means the cron job is running.
Can you provide some more information?
What are the permissions on bsc.php?
- From the command line type "ls -a /home/tcemcac/public_html/bsc.php" and post the output.
Which user are you when you configure the cron job?
from the command line what happens if you type "php"?
- You should get a blank prompt waiting for php input. Type "echo 'test'". If it repeats the word 'test' then php is working.
Can you paste the entire command line stuff you've just done so I can see what's going on?
Thanks