Jump to content


Photo

How to set up a nightly batch process?


  • Please log in to reply
12 replies to this topic

#1 loamguy

loamguy

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 25 May 2011 - 03:02 PM

Hi all,

Newb here with a few months of PHP experience.

I'm working on a project where if a web user signs up for a 30-day trial, they need to be notified near the end of that trial--let's say 25 days--that the trial is expiring. So I need some kind of batch process that runs in the background, perhaps every night at 1am, that looks at the signup date for all trial users and compares that date to the current date. If the difference is 5 days, then that user should be sent an email.

Does anyone know how to set up a nightly batch process that like this? I'm not concerned so much with the date comparison as I am with getting a daily process to run in the background. Coldfusion has something called a Scheduled Task, but being new to PHP, I don't know what would be comparable.

Any help welcome!

Thanks...

#2 cssfreakie

cssfreakie

    Advanced Member

  • Staff Alumni
  • 1,681 posts
  • LocationNorth Pole, left to the second polar bear that says howdy

Posted 25 May 2011 - 05:37 PM

you could have a look in to something called cronjobs

BEFORE YOU ASK: use a reset.css | use tables only for multicolumn data | Use a valid doctype | bad-tags
Posted Image
Did I help you? Consider donating ;)                         1phptut #mark your topic solved!!#

#3 jcbones

jcbones

    Advanced Member

  • Gurus
  • 2,543 posts
  • LocationNorth Carolina

Posted 25 May 2011 - 08:27 PM

If you are running a *nix server, use crontabs.  If you are running winDoze server, use task scheduler.

#4 loamguy

loamguy

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 28 May 2011 - 09:11 AM

Ok, thanks all!

#5 loamguy

loamguy

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 28 May 2011 - 09:49 AM

Looks like our godaddy server is hosting IIS and they say we won't have authority to create a task.

Are there any 3rd-party tools that could run a PHP URL once a day maybe?

#6 gevensen

gevensen

    Advanced Member

  • Members
  • PipPipPip
  • 205 posts

Posted 28 May 2011 - 09:59 AM

Looks like our godaddy server is hosting IIS and they say we won't have authority to create a task.

Are there any 3rd-party tools that could run a PHP URL once a day maybe?


surely godaddy has a chronjob in its cpanel, thats the way to go

#7 .josh

.josh

    .josh

  • Staff Alumni
  • 14,828 posts

Posted 28 May 2011 - 10:22 AM


Looks like our godaddy server is hosting IIS and they say we won't have authority to create a task.

Are there any 3rd-party tools that could run a PHP URL once a day maybe?


surely godaddy has a chronjob in its cpanel, thats the way to go


I'm sure they do..but he said that they said "we won't have authority to create a task".

...which means he's probably on a really cheap hosting plan.  Most really cheap hosting plans do not let you do things like that. 

Did I help you? Feeling generous? Donate to me! || Donate to phpfreaks!
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#8 jcbones

jcbones

    Advanced Member

  • Gurus
  • 2,543 posts
  • LocationNorth Carolina

Posted 28 May 2011 - 11:32 AM

Godaddy doesn't use cpanel.

#9 xyph

xyph

    Advanced Member

  • Staff Alumni
  • 3,712 posts
  • LocationSurrey, BC

Posted 28 May 2011 - 12:07 PM

I'm sure godaddy unix would allow a cronjob. He's on a godaddy windows server though.


Everything you need to know about storing user-names and passwords
http://www.openwall....Users-Passwords
Blank Page? Try forcing errors to display
ini_set('display_errors',1);
error_reporting(-1);

#10 .josh

.josh

    .josh

  • Staff Alumni
  • 14,828 posts

Posted 28 May 2011 - 12:14 PM

Right..and it would have its own cron equivalent.  Virtually all systems have ability to schedule execution of something on a regular basis...I assure you that's not the issue.

Issue seems to be that he's apparently not allowed to, and its probably because he has some super cheap hosting plan

Did I help you? Feeling generous? Donate to me! || Donate to phpfreaks!
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#11 xyph

xyph

    Advanced Member

  • Staff Alumni
  • 3,712 posts
  • LocationSurrey, BC

Posted 28 May 2011 - 01:31 PM

Because setting up a sched task for a windows user... hell active directory itself, is SUPER ANNOYING to deal with. Generally, sched tasks on shared hosting machines can lead to security issues.

nix does a much better job of handling this kind of stuff, and crons are easily made with specific user permissions.

That's why even cheap nix plans generally allow crons. I have set up crons on a client's economy godaddy hosting plan. I can even set up SSH if I'd like.

Your solution is to get GoDaddy to move you to a Linux server, and use a cron.
Everything you need to know about storing user-names and passwords
http://www.openwall....Users-Passwords
Blank Page? Try forcing errors to display
ini_set('display_errors',1);
error_reporting(-1);

#12 loamguy

loamguy

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 04 June 2011 - 10:23 AM

Yeah, we are stuck with IIS on this hosting package (there is both ASP.net and PHP involved).

Does anyone know of a 3rd party tool that could ping a PHP url? If I set up a file to poll MYSQL and send out emails, does anyone know of a service I could use to hit that URL on a nightly basis?

#13 xyph

xyph

    Advanced Member

  • Staff Alumni
  • 3,712 posts
  • LocationSurrey, BC

Posted 04 June 2011 - 11:22 AM

Set up a task on your home computer to visit a secret URL every night?
Everything you need to know about storing user-names and passwords
http://www.openwall....Users-Passwords
Blank Page? Try forcing errors to display
ini_set('display_errors',1);
error_reporting(-1);




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com