Windows Task Scheduler Issue (Cron Job)
Posted by: arnb (---.dyn.optonline.net)
Date: June 28, 2021 06:08PM

Have the following Windows (10) task scheduled to run every few days with the following action

C:\wamp\bin\php\php7.0.11\php.exe -f C:\wamp\www\cz\test\yadayada.php?Live

It works from the Task Scheduler Run action, cmd.exe and web browser, but fails with a 0X1 when started on schedule by the task scheduler. WAMP is active when it fails, however it works when started with the task scheduler Run action with WAMP inactive.

Any ideas on how to debug and fix this appreciated. I can't figure out how to get error messages from the scheduled execution and nothing shows in the Windows error messages.


PS Running Wamp 3.0.6 (yes it's out of date)

Options: ReplyQuote
Re: Windows Task Scheduler Issue (Cron Job)
Posted by: Otomatic (Moderator)
Date: June 28, 2021 07:24PM

Hi,

Install addon php 7.0.12 then run C:\wamp\bin\php\php7.0.12\php.exe from the task scheduler.

When Wamp is started, php7.0.11 is occupied by Apache and I think that it is the cause of the error.

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.6 32 bit - Apache 2.4.49 - PHP 8.0.9…5.6.40 - MySQL 5.7.35 - MariaDB 10.5.12/10.6.4
Wampserver 3.2.6 64 bit - Apache 2.4.49 - PHP 8.0.9…5.6.40 - MySQL 5.7.35/8.0.26 - MariaDB 10.5.12/10.6.4
PhPMyadmin 5.1.1 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Re: Windows Task Scheduler Issue (Cron Job)
Posted by: arnb (---.dyn.optonline.net)
Date: June 28, 2021 11:31PM

Appreciate the idea to update PHP, but it seems the problem is related to the ?Live get parm field.

It works as expected without the parm field when started by the Windows Task Scheduler, and fails when it is coded. Works as expected with the parm field from a web browser.

Fails
C:\wamp\bin\php\php7.0.11\php.exe -f C:\wamp\www\cz\test\yadayada.php?Live

Works
C:\wamp\bin\php\php7.0.11\php.exe -f C:\wamp\www\cz\test\yadayada.php

I could get rid of the parm field, but I prefer having a parm controlling this long running script.

Anyone know why the Windows task scheduler chokes with a parm field, or how to get around this issue?

Options: ReplyQuote
Re: Windows Task Scheduler Issue (Cron Job)
Posted by: Otomatic (Moderator)
Date: June 29, 2021 08:57AM

Hi,

> C:\wamp\bin\php\php7.0.11\php.exe -f C:\wamp\www\cz\test\yadayada.php?Live

Don't you think there is a problem with the parameter passing?

You are in CLI mode, the arguments must be separated by a space, not by a ?

e:\wamp64\bin\php\php7.0.33>php.exe -help
Usage: php [options] [-f] <file> [--] [args...]
php [options] -r <code> [--] [args...]
php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
php [options] -S <addr>:<port> [-t docroot] [router]
php [options] -- [args...]
php [options] -a

-a Run interactively
-c <path>|<file> Look for php.ini file in this directory
-n No configuration (ini) files will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse and execute <file>.
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-r <code> Run PHP <code> without using script tags <?..?>
-B <begin_code> Run PHP <begin_code> before processing input lines
-R <code> Run PHP <code> for every input line
-F <file> Parse and execute <file> for every input line
-E <end_code> Run PHP <end_code> after processing all input lines
-H Hide any passed arguments from external tools.
-S <addr>:<port> Run with built-in web server.
-t <docroot> Specify document root <docroot> for built-in web server.
-s Output HTML syntax highlighted source.
-v Version number
-w Output source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.

args... Arguments passed to script. Use -- args when first argument
starts with - or script is read from stdin

--ini Show configuration file names

--rf <name> Show information about function <name>.
--rc <name> Show information about class <name>.
--re <name> Show information about extension <name>.
--rz <name> Show information about Zend extension <name>.
--ri <name> Show configuration for extension <name>.

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.6 32 bit - Apache 2.4.49 - PHP 8.0.9…5.6.40 - MySQL 5.7.35 - MariaDB 10.5.12/10.6.4
Wampserver 3.2.6 64 bit - Apache 2.4.49 - PHP 8.0.9…5.6.40 - MySQL 5.7.35/8.0.26 - MariaDB 10.5.12/10.6.4
PhPMyadmin 5.1.1 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Re: Windows Task Scheduler Issue (Cron Job)
Posted by: arnb (---.dyn.optonline.net)
Date: June 29, 2021 10:08PM

> You are in CLI mode, the arguments must be separated by a space, not by a ?

Thank you for posting the documentation. I rarely work with the Windows Task Scheduler, so getting this working has been a challenge for me.

I changed the php script to run in live mode without a parm field and it's working as expected. I tried using the -parm option without success, but will try again. Also tried putting the parm into double quotes without success.


Question. what's the best/easiest way to create an output log.

Options: ReplyQuote
Re: Windows Task Scheduler Issue (Cron Job)
Posted by: Otomatic (Moderator)
Date: June 30, 2021 09:19AM

Hi,

> I tried using the -parm option without success
It should be:

C:\wamp\bin\php\php7.0.11\php.exe -f C:\wamp\www\cz\test\yadayada.php Live

If this is the Live parameter you want to pass to the yadayada.php script.

With:
C:\wamp\bin\php\php7.0.11\php.exe -f C:\wamp\www\cz\test\yadayada.php?Live
php.exe will want to execute the file "yadayada.php?Live" which does not exist.

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.6 32 bit - Apache 2.4.49 - PHP 8.0.9…5.6.40 - MySQL 5.7.35 - MariaDB 10.5.12/10.6.4
Wampserver 3.2.6 64 bit - Apache 2.4.49 - PHP 8.0.9…5.6.40 - MySQL 5.7.35/8.0.26 - MariaDB 10.5.12/10.6.4
PhPMyadmin 5.1.1 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote


Sorry, only registered users may post in this forum.