views:

50

answers:

4

How to test a cron job in Local Server like WAMP?

A: 

What do you mean by "a cron job"? On a lot of websites there is a special page like "cron.php" which is hit periodically, normally like so:

0 * * * * wget http://example.org/cron.php

In which case you just need to manually hit your cron php file to simulate the behaviour.

ZoFreX
"a cron job" mean cron
Starx
Well what I meant was, what is the cron job doing? In website terms "cron" is normally synonymous with "job that runs occasionally", which could be achieved with task scheduler or manually hitting it. If you literally need to test a crontab, that's a different problem.
ZoFreX
Ok, then how to use task scheduler to execute a PHP script in a certain Interval of time?
Starx
A: 

Install cron.

I wouldn't want to do that on Windows though. You'd probably be better off grabbing a copy of VirtualBox and creating something that better resembles your production environment to do your development in.

David Dorward
+1  A: 

Windows doesn't have Cron (it is the main task scheduling program for Linux systems). The Windows version for that is the Task Scheduler. This question recommends using the at command.

So that Cron doesn't have anything to do with the Apache, Mysql, PHP setup I don't think it is possible to reliably test the cronjobs you created for the Linux Cron in windows (maybe with Cygwin).

Daff
A: 

Simply run the job from the command line. It is the job that you're wanting to test, not cron itself. If you need to have it execute at periodic intervals to simulate cron, then use the Windows "Scheduled Tasks" facility

Mark Baker