HomeCoding & Programming

Setup Cron Job In Windows Using Wamp/Xampp Server?

Setup Cron Job In Windows Using Wamp/Xampp Server?
Like Tweet Pin it Share Share Email

You have to follow below some very simple steps to run cron file in windows system.

 

1. Create a cron.php file (the code you want to execute at a regular interval)

 

2. Create a CRON.BAT file, copy and past the below code in the file
D:\xampp\php\php.exe  D:\xampp\htdocs\Application\cron.php

 

The path I have written is according to my xampp and cron.php file, update the path of files according to your system directory

 

3. To schedule a task

Click on start > All Programs > Accessories > System Tools > Scheduled Tasks

Or you can go directly
Control Panel > Scheduled Tasks

Right click in the folder
New > Schedule Task

Give appropriate name to the Task.
In the RUN text field… Type the complete path of the CRON.BAT file

in my case it is
D:\xampp\htdocs\Application\CRON.BAT

Set the schedule of the job, you can use advanced button if required.

I hope this all will help you. Please leave your comment if you face any issue in setup cron job in windows 🙂

Comments (10)

  • This is very great article thanks for sharing………..

  • Its really great.
    But one issue is here:
    If I want it for certain time interval like every 5 minutes , then Schedule Task not supported. kindly help me regarding this.

    • Gopal..Sorry for late response.
      But you can set the scheduler that will run in every five minutes.
      There is setting under ‘Advance Setting’ TAB,that can be set/save according to your time.

  • Thanks a lot for the tips. It works really good.

  • For those who don’t want the console to pop up, run the cron as a VBScript

    Sample:

    Set WshShell = CreateObject(“WScript.Shell”)
    WshShell.Run chr(34) & “\\Path\\To\\Cron.Bat” & Chr(34), 0
    Set WshShell = Nothing

    Save the following code as Cron.vbs, and set that up in you’re task scheduler.

    I run this very script to scan my downloads folder for *.TORRENT files and move them over the network to my Transmission torrent client.

    Hope this helps.

  • Great tutorial, thank you!!! this was really useful :))

  • Excellent. worked just fine

  • Very good work, thank you.

  • I done all steps now i am on last stage on creating task i give name after that a location field is showing but the location field textbox is just readable i am not able to write or paste the location “C:\xampp\htdocs\kd\CRON.BAT” , and i am not seeing any advance setting option, bascially i am using windows7

  • Thank you for sharing.

    http://allinonescript.com for programming Doubts and solutions …

Comments are closed.