0

Task Scheduler Log I'm trying to schedule a codeigniter php file in Windows Task Scheduler. I have tried using .bat file as follows:

php E:\UniServerZ\index.php mailtry mailsend

where mailtry is controller name and mailsend is controller function

I have also tried scheduling using powershell script using url as follows:

First:

powershell -ExecutionPolicy Bypass -Command
        Invoke-WebRequest 'https://abcd.hub/abcd/mailtry/mailsend' -UseBasicParsing

Second:

$url = "https://abcd.hub/abcd/mailtry/mailsend"
PowerShell Invoke-WebRequest -Uri $url -Method GET

Third:

explorer "https://abcd.hub/abcd/mailtry/mailsend"

Nothing works. How to schedule this? Any help is much appreciated.

13
  • Nothing works isn't a useful description of your problem. What exactly goes wrong when you try these various approaches? We can't fix a problem if we don't know what the specific fault is, and we also don't know what your PHP code looks like. Commented Mar 3, 2021 at 10:03
  • Nothing works here means upon scheduling these, nothing happens. Literally! No errors and no warnings. I haven't provided php code as I just want to schedule it. Commented Mar 3, 2021 at 10:10
  • So, are you saying that if you put https://abcd.hub/abcd/mailtry/mailsend into your browser it would work no problem and send the mail? Commented Mar 3, 2021 at 10:12
  • 1
    have you tested these command-line approaches independently without the scheduler? E.g. if you open a powershell window and write one of your attempts such as Invoke-WebRequest -Uri $url -Method GET , does it send the request? You can use a network monitor to test, if you don't get any output from powershell directly, and/or you can check the server logs, see if it received the request or not, and what status code it had. In other words, there's plenty more debugging you can do here to discover precisely what is happening / not happening. Narrow it down. Commented Mar 3, 2021 at 10:14
  • 1
    Have you also checked the access log to see if your PHP gets any requests at all? It might not produce an actual error but still fail to do what it suppose to do for some unknown reason? Commented Mar 3, 2021 at 10:54

1 Answer 1

1

Hoping that if you go on a browser and execute that link it successfully works.

Then you can actually configure a task scheduler to open a certain browser then go for that link to execute.enter image description here

At step 1 from the image put a path for a browser program like Firefox or google chrome within double quotes. e.g "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"

Then at step 2, simply add a link you wish to execute.

Then save your Task, you are done from there.

Reference: https://windowsloop.com/open-webpage-on-schedule-task-scheduler/

All the Best

Sign up to request clarification or add additional context in comments.

1 Comment

Sure you're welcome, don't forget to give some credits @AnushreeBharadwaj

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.