Scheduling jobs to send email alerts and notifications.

Hello Everybody,
I have a blank application which sends emails to users as daily tasks get updated in database. Whenever I run this application, it works good, sends email to defined recipients. I need to add job scheduler in my application so that this blank application will run everyday at specific scheduled time and sends updates of tasks to defined recipients group.

I thought calling the php file of application from php cli will be solution, but it is not working. Following command displays the output of my application which I need to run in order to send notification using scheduling jobs.


$php -r app_name/app_name.php
<html ....>
<....>
.............................
</....>
</html>

This is needed to run program from command line because in crontab file, we need to write commands which will run these jobs, which I already written in blank application.

Thank you for reply

I don’t have an exact answer to that, as I have not tried that yet. I do have some blank aps I am counting on running from a cron job though, so please post any solution here.
There is another way BTW - you could execute your app as a webpage - like you do as from the browser, BUT it can also be done using wget, a linuc command. That way, you have a cron job or even an external service hit that app anytime you want. Here is a how to: http://stackoverflow.com/questions/5766772/using-wget-to-run-a-cronjob-php

Jamie

I don’t have an answer too I’m affraid, but am in the same situation. Need to develop some cron apps soon.

Jamie,
Following are results. I am getting response 200 which is permission denied.

$ sudo wget --spider http://www.websitename.com:8888/application/emailSender/emailSender.php
Spider mode enabled. Check if remote file exists.
–2013-10-23 15:59:25-- http://www.websitename.com:8888/application/emailSender/emailSender.php
Resolving www.websitename.com… xxx.xxx.xxx.xxx
Connecting to www.websitename.com|xxx.xxx.xxx.xxx|:8888… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [text/html]
Remote file exists and could contain further links,
but recursion is disabled – not retrieving.

$ sudo wget -O /dev/null http://www.websitename.com:8888/application/emailSender/emailSender.php
–2013-10-23 16:02:39-- http://www.websitename.com:8888/application/emailSender/emailSender.php
Resolving www.websitename.com… xxx.xxx.xxx.xxx
Connecting to www.websitename.com|xxx.xxx.xxx.xxx|:8888… connected.
HTTP request sent, awaiting response… 200 OK
Length: 1065 (1.0K) [text/html]
Saving to: `/dev/null’

100%[=============================================================>] 1,065 --.-K/s in 0s

2013-10-23 16:02:39 (43.6 MB/s) - `/dev/null’ saved [1065/1065]

$ sudo wget -q --spider http://www.websitename.com:9000/application/emailSender/emailSender.php

$ sudo wget -O- http://www.websitename.com:8888/application/emailSender/emailSender.php >> /dev/null
–2013-10-23 16:05:56-- http://www.websitename.com:8888/application/emailSender/emailSender.php
Resolving www.websitename.com… xxx.xxx.xxx.xxx
Connecting to www.websitename.com|xxx.xxx.xxx.xxx|:8888… connected.
HTTP request sent, awaiting response… 200 OK
Length: 1065 (1.0K) [text/html]
Saving to: `STDOUT’

100%[=============================================================>] 1,065 --.-K/s in 0s

2013-10-23 16:05:56 (44.4 MB/s) - written to stdout [1065/1065]

What does the site give when you run the command via a browser?
Be aware that wget does NOT interpret javascripts whereas a browser does.
You cold be faster of by making a simple commandline php program that does the mailing and run that in a cron job. That is really
fairly easy to do and it would always run.
If you are on a windows machine and you are a bit lazy you can use iopus imacros and build a small thing that does whatever you need behind a browser. Or alternatively use autohotkey with the ahk addon.
That would be fairly the same is opening a browser and doing it by hand, but now it is done by automation…

I use a freeware program called robotask…
does ALOT!!!