How to create CRON jobs (Scheduled Tasks) in WAMP
August 9, 2014 / by Marco / Categories : TechnologyWhat is WAMP?
WAMP is a Windows based web development platform that allows you to create web applications with Apache2, PHP and MySQL. It is basically a package that you run on your Windows OS and it will turn the device into a web server.
What is a CRON job?
Ok, so CRON jobs is something that you would find in Unix system. On a Windows based system it’s actually called Scheduled Tasks. I find Windows scheduled tasks to be much easier to setup than CRON jobs but they do exactly the same thing. They run a task in the background at a specified internal.
In this post I will only detail the steps required to create a scheduled task for a web application running on WAMP.
ADD folder Path for PHP.exe
Click Start
Right Click Computer – Properties
Click Advanced system settings
Click Environment variables
At the end of the line add:
C:\wamp\bin\php\php5.5.12
Check to make sure the php.exe file exists in that folder. You may have a different folder name depending on the version of php.
Make sure you include the semi quotation marks ;
To verify to make sure it worked just open up the command prompt and type
set
This will display all your variables and you should see the php folder listed. Something like this:
BATCH FILE
Create a batch file (open up a text editor like notepad and make sure you save the file as cron.bat. If the filename is cron.bat.txt then this is not a batch file)
@echo off
REM -----
REM Created By Business Legions www.businesslegions.com/blog
REM Cron job in WAMP
php -f C:\wamp\www\abc.php
You can also download the attached example.
Cron Batch File for WAMP
To run a specific page to trigger certain events use the following syntax
For executing a file:
php -f C:\wamp\www\abc.php
For downloading a file you will need to get the windows based version of wget.
http://sourceforge.net/projects/gnuwin32/postdownload?source=dlp
Install the software and then add the path:
C:\Program Files (x86)\GnuWin32\bin
To the environment variables – see above steps
For executing a website:
all you need to do is add the program script
“C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”
CREATE SCHEDULED TASK
Click Start
Right Click on Computer and select Manage
In System Tools, Expand Task Scheduler and Click on Task Scheduler Library. Create a new task:
Set the Trigger settings eg frequency.
Set the action. In this particular example browse to the cron.bat file.
The conditions and settings tabs are pretty much optional. Click ok and then the task will run based on the frequency you set.
It should say running next to the task name.
That’s it. The cron job will now run.
SILENT BAT
UPDATE: If you don’t want to have the Command window popup you can run the batch file within a Visual Basic script. To do this follow these steps:
Create a new file called cron.vbs and put in the following text. Replace the C:\Scheduled Jobs\cron.bat with the location of your batch file.
Then in the task scheduler for the Action, select the file cron.vbs instead of the cron.bat file. This will run the batch file silently.
Below is the cron.vbs file.
CRON VBS FILE
Our Sponsors
- Advertise Me Pty Ltd
Digital Signage Solutions
OTHER ARTICLES YOU MAY LIKE
USING BUTTERNUT.AI TO CREATE PROFESSIONAL WEBSITES
Having a professional and efficient website is crucial for any business looking to thrive online. With the constant advancements in technology, it can be overwhelming to keep up with the latest tools and platforms available for website creation. However, by leveraging the innovative capabilities of Butternut.ai, businesses can maximize their efficiency and create stunning websites […]
read moreEASY AND SIMPLE AI VIDEO EDITING SOFTWARE
Imagine your favourite movie scene transformed into a video in minutes, not hours. Thanks to advancements in technology, editing software has become increasingly user-friendly. Wondershare’s Filmora 14 stands as a prime example, boasting an array of AI features that simplify the editing process, with AI voice capabilities that could turn your voiceover dreams into a […]
read more