Cron Type Application w/o Using Windows scheduled tasks?
Posted by: kendor (---.dyn.optonline.net)
Date: April 21, 2012 10:51PM

Am trying to deliver an Intranet reporting application to customers that automatically emails reports to distribution lists. In some cases there maybe many jobs, and scheduling our PHP scripts to execute via the Windows task scheduler seems very cumbersome. It would be much better if there was a way to bake this into our app, especially from a web GUI standpoint. Using an outside cron service is NOT an option because of firewall constraints.

Would love some suggestions on this...



Edited 1 time(s). Last edit at 04/21/2012 10:58PM by kendor.

Options: ReplyQuote
Re: Cron Type Application w/o Using Windows scheduled tasks?
Posted by: stevenmartin99 (Moderator)
Date: April 21, 2012 11:06PM

build a simple windows service to run it. - its the only reliable way

i have seen a new php service wrapper that will allow php code to be built as a service.

you may also want to look at winbinder that allows for access to the WinAPI.



But TaskScheduler does have a command line that you could probably use to setup from a script>>[technet.microsoft.com]


or a cron exe built for windows >> [www.cronforwindows.com]

you cant have it IN your app because a HTTP server responds to requests, its not checking for something to happen...

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 1 time(s). Last edit at 04/21/2012 11:07PM by stevenmartin99.

Options: ReplyQuote
Re: Cron Type Application w/o Using Windows scheduled tasks?
Posted by: kendor (---.dyn.optonline.net)
Date: April 21, 2012 11:13PM

Since this is an Intranet app, I would think there could be some sort of daemon that could be run, that could be talked to a web-based front end...

Seems like a very common problem... and thought that there would likely be a pre-baked solution...

Options: ReplyQuote
Re: Cron Type Application w/o Using Windows scheduled tasks?
Posted by: stevenmartin99 (Moderator)
Date: April 21, 2012 11:28PM

then you can use pycron written in python >> [www.kalab.com]

once installed , click start > run> services.msc

right click python cron service and press start. it should be set to automatic so it will startup with the pc from
now on

there is in a editor at c:\program files\pycron\pycroneditor.exe to add jobs but you could get your script
to automatically add lines directly to the "job file"

there is a file called pycron.cfg.sample > rename this to pycron.cfg

you can edit this and tell the service where to look for the file but by default it looks for crontab.txt in the same folder.

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Cron Type Application w/o Using Windows scheduled tasks?
Posted by: kendor (---.dyn.optonline.net)
Date: April 21, 2012 11:37PM

Steven, this look like a promising approach and fairly easy...

Do I have this right...As long as pycron was running, and we had "write" access to the "job file" and we understood the format properly, we could build a web page that displays current jobs, but also allows one to modify them?

Options: ReplyQuote
Re: Cron Type Application w/o Using Windows scheduled tasks?
Posted by: stevenmartin99 (Moderator)
Date: April 21, 2012 11:54PM

yes set the path of the jobfile to a location in your intranet project so that php can edit it.

but thats where you would have some work to do...

you will need to write a script that can write a cron job... i dunno if you know how they work but its just

* * * * * * "file.exe paramaters "

the stars will be numbers about weeks,days, hours, and mins and the repeat time. it can be a little tricky to
get your head around so maybe take a look at their editor and the output file and see how it does it ( there is good documentation with this explaining exactly how it works)

i am presuming you might need to be running php scripts to do the exporting of reports?

you will be best to add a Enviormental Variable to windows for php so that you can just write seomthing similar to

* * * * * * * "c:\windows\system32\cmd.exe" /c php "script.php"


i guess you will have to write a little form for end users where they can add, edit and delete crons.

you might want to stop the service while editing the file.. there is a php extentions

>> [www.php.net] that can manage that

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote


Sorry, only registered users may post in this forum.