PHP CLI and Task Scheduler problem - windows

I thought I had set up a successful schedule in Windows to run a PHP script. But all I got was an error which slaps only when run through the task scheduler.
Here is how I run the task:
I created a batch file runCron.bat:
start php.exe reportGenerator.php
and placed reportGenerator.php in the same folder as of the batch file.
When I manually execute the batch file, all is well. But when the same batch file is called by the task scheduler, PHP CLI throws the following error:
Could not open input file:
reportGenerator.php
What would have been missed? I understand it's a path issue, but where exactly is the issue?
Thank you for any help.

try
start php.exe -f c:\full\path\to\reportGenerator.php
it probably looks for the script in the schedulers working directory, not in the bat file dir

Related

Open and run .qvw (qlikview) file through Jenkins

To Run a qlikview file I am using batch file it is working fine ,I am using below command in batch file "path\qv.exe" /r "path\myapplication.qvw"
When I am trying to run above batch command through jenkins job it is continuously running.
"path\qv.exe" /r "path\myapplication.qvw"
The related post is here
How to run .qvw (qlikview) file through Jenkins
THe sulution is just go to services.msc and log on as a administrator then in jenkins create a project and call a batch command having below command, "path\qv.exe" /r "path\myapplication.qvw".It will do the job.
Question: go to services.msc for what?
what is the detail steps to solution this issus:jenkins job it is continuously running.
Go to services.msc and select the Jenkins service and log on the Jenkins service as a administrator in the Jenkins service log on page.
In jenkins create a project and call a batch command having below command, "path\qv.exe" /r "path\myapplication.qvw".It will do the job

Cant execute bat file via Jenkins

The following bat file is working when running this directly on the machine.
#ECHO OFF
echo Starting the Application ...
START "app" java -jar app-0.0.1.jar
When calling this file via Jenkins it's not working.
Any idea why?
Thank you

How to run bat file in jenkins

My jenkins is installed in C:\Program Files (x86)\Jenkins
bat file is located in C:\Users\Admin\workspace\demoWork\run.bat
When i run this bat file from cmd everything works fine. But when i try from jenkins executing batch command as mentioned in Image, Jenkins displays error as
Build step 'Execute Windows batch command' marked build as failure
Also inside jenkins folder automatically workspace folder gets created with Job title name. Can you guys please explain me in detail
Tatkal, you can't execute a command like in your image,
why don't you simply try
C:\users\admin\workspace\demowork\run.bat
or
call "C:\users\admin\workspace\demowork\run.bat"
"Also inside jenkins folder automatically workspace folder gets created with Job title name. Can you guys please explain me in detail" -
Jenkins creates folder with job title name automatically, saves jobs data and other build info... this is how it works. By default in jenkins job you can access your workspace using $WORKSPACE variable
You have put very little detail into this so I'm going by pure guess..
The Execute Windows batch command is to literally execute code, not execute a file.. to execute the file you could use this command :
start cmd.exe /c C:\myprj\mybat.bat
or you could take the contents of the .bat file and rewrite in in that command line..
The way Jenkins works is it creates its own workspace for each job, essentially to sandbox the environment, its a testing framework so it should be used to stage changes to code, which will then be pushed to your live(working) environment. People use it to automate some tasks, but this isnt the primary use of Jenkins.. if the above doesn't help you let me know more details of the error and I can try help you with it.
node {
bat 'D:\\gatling-charts-highcharts-bundle-3.0.2\\bin\\gatling.bat'
}

Windows Bat file run from Autosys - Failed to load the sqljdbc_auth.dll

I have a question and wondering if you guys could help.. Here are the details -
Program Flow ->
Autosys Job -> Windows .bat job on network path-> Internally calls java program along with few other components
When the .bat runs through Autosys job, it gives below warning and does partial processing and exits out without any failure
(i guess the internal code might not have good error handling..but sadly I do not have access to view/modify the same). However, when I logon to that
windows box and run the .bat file from cmd prompt, it works like a charm and throws no error.
Warning in Logs - "WARNING: Failed to load the sqljdbc_auth.dll"
Things I tried-
I tried creating a wrapper bat file in windows C drive (not the netwrok path where the actual .bat is in) and placed sqljdbc_auth.dll in that custom folder.
Job went to SU , after partial processing.
Appreciate your help.
Many Thanks,
Raj
I'd suspect there is a path error. Try echo %path% just before calling your batch, even simply run
echo %path%>alogfile
call yourbatch
and if the displayed path doesn't include a directory in which your .dll resides, add it into the path before calling yourbatch.
It may very well be that your logon includes the required directory as part of your user-defined path and the username under which the job runs does not include the directory.
Or, you could try moving the dll into somewhere like system32 which should be common to everyone.
(Windows should use the standard path-scanning algorithm to locate any required dll that isn't invoked from a full pathname)

Windows Scheduled Task not working for PHP script

I'm using Windows Server 2003 to try and execute a PHP script every day at 9AM. Here's the command inside of run:
"C:\Program Files\Zend\ZendServer\bin\php.exe" C:\Program Files\Zend\Apache2\htdocs\signout\teachernotify.php
It's supposed to execute the PHP script above which is supposed to e-mail me, but it doesn't work. Accessing the script above through a browser works, but not through Scheduled Tasks.
When I run it through the task scheduler, it goes through like something happened, but it doesn't appear to work.
Any advice?
Thanks
It sounds like it could be a permissions problem. When run through Apache via a web browser, the permissions would be based on whatever permissions Apache is running under. As a scheduled task, the permissions are based on the user specified for the task.
Make sure that the user specified in the "Run as" field in the task settings dialog has permissions to send an email.
Based on your most recent comment, it seems the problem is that the filename needs double quotes around it. I failed to notice that in the original question.
"C:\Program Files\Zend\ZendServer\bin\php.exe" "C:\Program Files\Zend\Apache2\htdocs\signout\teachernotify.php"

Resources