jemz — 2013-06-03T14:32:55-04:00 — #1
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.
scallioxtx — 2013-06-03T14:58:17-04:00 — #2
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))
jemz — 2013-06-04T04:40:30-04:00 — #3
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.
jemz — 2013-06-04T04:56:38-04:00 — #4
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.
scallioxtx — 2013-06-04T06:01:42-04:00 — #5
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.
jemz — 2013-06-04T06:17:24-04:00 — #6
Oh,I see..so cron is for the linux only...That's why i could not understand the command...Thank you again.
vectorialpx — 2013-06-04T07:23:59-04:00 — #7
jemz — 2013-06-04T07:45:14-04:00 — #8
i followed in the stackoverflow but it doesn't work...
prince55l — 2013-06-04T13:33:46-04:00 — #9
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.
scallioxtx — 2013-06-04T15:16:15-04:00 — #10
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.
drummin — 2013-06-04T16:56:30-04:00 — #11
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.
jemz — 2013-06-05T06:36:33-04:00 — #12
Hi, I already tried in the windows task scheduler,Thank you for your help.:)
mlbx02 — 2013-06-07T10:54:54-04:00 — #13
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.