0

I am trying to execute a PHP script at the predefined time. For instance, how can I write a php script that will force that script to be run on March 24th, 2013 at 11:14am(even if the browser is closed). I heard about cron but it is not clear to me.

Thank you for reading

3 Answers 3

3

Indeed cron could be an answer to your question. It is a special program that is in Linux systems and runs defined programs/commands on given time or periodically. Look here: http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5

Sign up to request clarification or add additional context in comments.

Comments

0

This would be quite troubling to do in PHP. I suggest you use something like Cron's Jobs to do this. Most cPanels have CronsJob on them, but if you don't take a look at this tutorial: http://www.thesitewizard.com/general/set-cron-job.shtml

2 Comments

Uh, you can write cron jobs in PHP.
like so: net.tutsplus.com/tutorials/php/managing-cron-jobs-with-php-2 but it's just as easy to do it with a control panel. I think the post needs to go a bit more in depth about cron jobs.
0

You will have to look at what is available to you in your hosting environment. Linux/Unix with command line access? Cron is probably your answer (http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/). If you are using a windows server, Windows Scheduled Tasks will work (http://support.microsoft.com/kb/308569). If you have cPanel or something like it (a lot of hosting solutions use it), then you will have to check the documentation for how to schedule tasks.

I disagree with Racialz, PHP command line (CLI) is just fine for this kind of work, I have even done svn hooks in php before. The best answer for what to use can often be what you are most comfortable with.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.