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.
need your help
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: need your help
Make a cron job.
Re: need your help
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:
This will run your script at midnight every night. - Tweak the zeros and stars to change the schedule.
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
Re: need your help
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
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
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: need your help
Do you know how to create a cron tab? Do you use PHPMyAdmin or something similar?
Re: need your help
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.
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
/home/tcemcac/public_html/bsc.php: Permission denied
Re: need your help
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
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