Hi, I just want to ask some help on how to use cron,I am not familiar on this and i want learn on how to use this or apply this in php,can you help me please where should i start...
Thank you in advance.
Via cron scripts you can fire up any executable script on linux at any time you wish. For example you can send out a newletter every day around midnight, clean out uploaded files every hour, checking for incoming mail every minute, etc, etc.
To find out more about cron checkout the man page, which explains it all.
What you need to be aware of when running a php script from cron, is that 1) cron doesn't have the same PATH you do, so mostly just calling
php won't work, it needs to be
/bin/php or something like that (type
which php to find out where php is located on your system). And 2) the current directory when running the the php file doesn't necessarily have to be the directory the php file is in.
The best solution for both 1 and 2 is to use absolute paths for everything (or use DIR (or dirname(FILE) for pre-5.3 php versions))
Hi ScallioXTX,thank you for the reply..Is this compatible in windows 7 ?,...is this also will work if i am in my localhost?
Thank you in advance.
Hi ScallioXTX, I could not get in this cron,...their is no steps...
so for example i have this php file C:\wamp\www\CronTest\crontest.php
inside of this crontest.php
echo "Test cron";
what is the next thing to do, do i need to open the command prompt and type those example commands that the link provided ?...I am confuse on this.please help me.
Thank in you in advance.
Windows doesn't have cron. Windows has the task scheduler. I have no experience with it, so I'm not able to help in that regard. Sorry.
Oh,I see..so cron is for the linux only...That's why i could not understand the command...Thank you again.
i followed in the stackoverflow but it doesn't work...
If you want to run this script as a schedule script like say, one or twice in a day, week, month or year, just go to your cpanel control panel and you will see cron schedular which you will use to call up your script.
Cron is mainly used to automate task.
The OP is running this on their local windows machine, so I'm pretty sure they don't have cPanel on there. Besides, under the hood cPanel is using cron for these kinds of tasks as well, you just don't notice it because you don't interface with it directly.
You might look into "fakecron". I used it on a windows project and it worked well once path issues were sorted out. Unlike cron where you'd set a time it relies on a page hit to trigger the script.
Hi, I already tried in the windows task scheduler,Thank you for your help.:)
To become more comfortable with the cronjob scheduling aspects of your question, try the interactive cron simulator at http://www.dataphyx.com/cronsandbox/. It gives you the chance to try out different values of the crontab timing parameters to see what run-times you would get.