Developer Snippet Diary

Run php files usign Cronjobs on localhost using task schduler ||PhP

set script.bat paths..

set script path in shellscript.vbs

  1. Open Task Scheduler using run command (taskschd.msc)
  2. Go to >Action menu>Create Task
  3. Fill the Name and Description
  4. Triggers tab, hit New button >schedule and choose Daily
  5. Advanced settings
  6. select Repeat task every (time) && Indefinitely.
  7. Actions tab >select Start a program.
  8. and give path of your .vbs file

ShellScript.vbs

Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\xampp\htdocs\cronJob\script.bat" & Chr(34), 0
Set WinScriptHost = Nothing

Script.bat

"C:\xampp\php\php.exe" -f "C:\xampp\htdocs\cronJob\index.php"

index.php

<?php
   file_put_contents('./rizi',date('h:i:s')."\n",FILE_APPEND);
?>
Posted by: R GONDAL
Email: rizikmw@gmail.com