Jump to content

Recommended Posts

So I have a php script in public_html on my apache server, and it runs a global economy code for my browser game.

If I open firefox and go to:

http://localhost/Economy.php

it runs the code, and it changes all the values in the database properly.

How do I get that to run automatically, say every 6 minutes?

 

I have windows so no cron jobs.

I went to task scheduler and created a task which I thought would work, and it lists the task as running.

But it gives me an error.

 

Event Views:

Log Name:      Microsoft-Windows-TaskScheduler/Operational
Source:        Microsoft-Windows-TaskScheduler
Date:          9/28/2011 5:02:37 PM
Event ID:      101
Task Category: Task Start Failed
Level:         Error
Keywords:      (1)
User:          SYSTEM
Computer:      Matt-PC
Description:
Task Scheduler failed to start "\Economy" task for user "Matt-PC\Matt". Additional Data: Error Value: 2147750687.

Event Xml:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-TaskScheduler" Guid="{DE7B24EA-73C8-4A09-985D-5BDADCFA9017}" />
    <EventID>101</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>101</Task>
    <Opcode>101</Opcode>
    <Keywords>0x8000000000000001</Keywords>
    <TimeCreated SystemTime="2011-09-28T22:02:37.967669800Z" />
    <EventRecordID>18</EventRecordID>
    <Correlation />
    <Execution ProcessID="1012" ThreadID="1484" />
    <Channel>Microsoft-Windows-TaskScheduler/Operational</Channel>
    <Computer>Matt-PC</Computer>
    <Security UserID="S-1-5-18" />
  </System>
  <EventData Name="TaskStartFailedEvent">
    <Data Name="TaskName">\Economy</Data>
    <Data Name="UserContext">Matt-PC\Matt</Data>
    <Data Name="ResultCode">2147750687</Data>
  </EventData>
</Event>

 

EDITed for code tags

Link to comment
https://forums.phpfreaks.com/topic/248067-running-a-php-script-at-an-interval/
Share on other sites

What's the actual command line that you are having the scheduler execute? It would need to contain php's CLI and your .php script file name. From your other thread on this -

 

You would use php's command line interpreter (CLI) - http://us2.php.net/cli

If you go to the TS and click create task, there is a part called action and it says:

Action(drop down):

I select:

Start a Program

Settings:

Program/Script:

 

Browse

 

I hit browse and find the script and it displays it in the form thingy.

 

after browse it has

Add Arguments(optional):

Start in(optional):

 

those have an input box.

 

It has a part called trigger that does the when do you run it part.

 

I do not understand what you mean by command line.

The thingy i posted in the first post describes the event as far as i can tell.

 

 

okay so i figured out how to open the php command line. but i don't understand how the command line connects to the task scheduler?

should i be including something in the script/program input prior to C:\Server\www\myserver.dev\public_html\Economy.php ?

You need to tell the Task Scheduler to OPEN the PHP CLI and run your script.

I assume you are browsing and finding your Economy.php file, this is incorrect.

Try entering this into the "Program/Script" portion

php.exe "C:\Server\www\myserver.dev\public_html\Economy.php"

if that fails try and enter the path to PHP

C:\path\to\php.exe "C:\Server\www\myserver.dev\public_html\Economy.php"

http://forums.techarena.in/vista-help/814945.htm#post3150172

 

Ah, that looks better. 2147943645 is a standard Windows HRESULT, defined in

Winerror.h:

 

# as an HRESULT: Severity: FAILURE (1), FACILITY_WIN32 (0x7), Code 0x4dd

# for decimal 1245 / hex 0x4dd

ERROR_NOT_LOGGED_ON

# The operation being requested was not performed because the

# user has not logged on to the network.

# The specified service does not exist.

 

So, it looks like the Task was unable to run because its user context,

BlackComputer\Bob, was not logged on. But, I guess you have the "Run whether

the user is logged on or not" option selected. So it's still a bit

perplexing ...

You need to tell the Task Scheduler to OPEN the PHP CLI and run your script.

I assume you are browsing and finding your Economy.php file, this is incorrect.

Try entering this into the "Program/Script" portion

php.exe "C:\Server\www\myserver.dev\public_html\Economy.php"

if that fails try and enter the path to PHP

C:\path\to\php.exe "C:\Server\www\myserver.dev\public_html\Economy.php"

 

This! I love you. Thank you so much. It works! I don't have to learn vb or C++! Thank you Jesus!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.