Results 1 to 14 of 14

Thread: Something like "cron/scheduled task" to run php question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Post Something like "cron/scheduled task" to run php question

    Dear all,
    I have to write a website which can register member, keep pets and save their money in the bank. The website will be placed in win XP wamp server.
    First, I have a situation. When a member registered an account in my website, he will receive an e-mail with a link, he must click the link to activate his account, otherwise after 24 hours later, the account will be automatically deleted by the system. So every member has his own count-down 24 hours respectively. I think cron/scheduled task can help me to do this task, but it seems that I need to run the php every second, minute or hours to access the database. That is a hard loading if my database has many members and waste the resources to handle this task.

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Something like "cron/scheduled task" to run php question

    This should be the process:

    1. Member Registers
    2. Time Set To 24 hours past current time
    3. Saved in Database
    4. Email sent with a link that has a special confirmation number/hash
    5. When they load the page to confirm, it check the database if 24 hours has past
    6. If it is 24+, you can delete the account and tell them their time is past; or if it is 24- confirm account.
    My usual boring signature: Something

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: Something like "cron/scheduled task" to run php question

    Ya, that's pretty nice job, but my aim is to save the memory of my database. If he never click the link, the row will keep in my database forever.

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Something like "cron/scheduled task" to run php question

    thats where you run a cron job every month or so to delete the rows that are 24+
    My usual boring signature: Something

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: Something like "cron/scheduled task" to run php question

    Thanks to your tips!I think I have an idea to handle the problem.

    My second situation, I have a dummy online bank. The accrual is 0.05 per month. The accrual must be changed in every 3 months, so in one year, there is 4 times changing. How do the both of cron job and user trigger to cooperate with the banking system?

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Something like "cron/scheduled task" to run php question

    Use a script triggered by a cron task to add the interest to all accounts at the end of every month (or week, or whenever you wish) and calculate the interest rate at that time.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: Something like "cron/scheduled task" to run php question

    If the php has been run at the end of month, but some of the users doesn't reach "one month". As a result, should the program be run everyday to calculate how much of interest adding to accounts?

  8. #8
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Something like "cron/scheduled task" to run php question

    that is a waste of memory. Because if you run that script every day, and it does through all of the records, that wastes memory.

    I would do it on the 30th of every month and if the member has not been there a full month, then they wont get it until next month.
    My usual boring signature: Something

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Something like "cron/scheduled task" to run php question

    What exactly do you mean by "doesn't reach one month"? You could have a system where any accrued unpaid interest is paid out when an account is closed.

  10. #10
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Something like "cron/scheduled task" to run php question

    he means like, they get x amount of interest per month, well what if they start in the middle of the month... they havn't been signed up for a fill month
    My usual boring signature: Something

  11. #11
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Something like "cron/scheduled task" to run php question

    Run the script at the end of month and calculate interest on a per-day basis. You do not need to run it every day to do this.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: Something like "cron/scheduled task" to run php question

    ya, just like dclamp means.
    I have $4000 and save it into bank at 15/8, and the program is run at the end of month, the interest is 0.05. Now I change the interest to 0.15 at 1/9, when at the end of september, my amount will be counted at 0.15 but not 0.05. This is the problem I worry about.

  13. #13
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: Something like "cron/scheduled task" to run php question

    Quote Originally Posted by dclamp
    that is a waste of memory. Because if you run that script every day, and it does through all of the records, that wastes memory.

    I would do it on the 30th of every month and if the member has not been there a full month, then they wont get it until next month.

    February doesn't have 30 days...

  14. #14
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Something like "cron/scheduled task" to run php question

    Thirty days has September, April, June, February and November,
    All the rest has thirty one, except February alone,
    Which has thirty days clear,
    And twenty nine in each leap year.
    Nahh, it doesn't sound right.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width