11
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/5/30 9:15

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


i didnt notice previously! you said to rewrite the code in sql, do you mean i can run this kind of code with sql? I could run an sql query for example to compare a value of the table with the current time stamp and act according to the result???

I was about to rewrite the code in php and i wanted to ask about security issues regarding the db pass etc when i realised what you suggested! :)
whttp://www.guidemap.gr - Beta is out...

12
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/5/30 9:39

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


i found it mate! Thanks for your help! The sql statement should be like the following in case anybody else faces the same prob...
Quote:

UPDATE `table_name` set whatever WHERE date<=CURRENT_TIMESTAMP AND expdate!=0
whttp://www.guidemap.gr - Beta is out...

13
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/5/30 12:46

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


i found out that when i run the following command

Quote:

UPDATE `table_name` set status =2 WHERE expdate


that makes the status of every new db entry including the ones i made today equal to 2, and takes them ofline!

Each time i add an entry i set

Quote:

$expdate = time() + (30 * 24 * 60 * 60);


to make the expiration date after 30 days

then in the sql statement i check if that date is less than the current time stamp and if it is yesterday for example take it offline! But the code doesnt seem to work! Any suggestions?? I just want to check if the expiration date is passed!
whttp://www.guidemap.gr - Beta is out...

14
mboyden
Re: How to make a function similar to a cron job...
  • 2008/5/30 13:29

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


Yep, that code won't work, but you're on the right track. Might be best to visit more of the documentation on the MySQL language.

Your problem is CURRENT_TIMESTAMP. For instance in you run this SQL statement:
Quote:
SELECT CURRENT_TIMESTAMP;

then you get:
Quote:
2008-05-30 08:10:06

So, what you need to change this to is one that uses an appropriate comparison:
Quote:
UPDATE `table_name`
SET status =2
WHERE expdate <= UNIX_TIMESTAMP() AND expdate != 0
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

15
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/5/30 13:44

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


thanks mate! works like a charm, or so it seems so far cheers
whttp://www.guidemap.gr - Beta is out...

16
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/6/1 16:45

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


back again! the previous prob was solved! i made a record to expire the next day but the sql statement did run! do you think it has to do with the server being a windows one??? Clicking the 'do it now' link it works fine, but it doesnt seem to run the sql script auromatically every day as configured!!!
whttp://www.guidemap.gr - Beta is out...

17
mboyden
Re: How to make a function similar to a cron job...
  • 2008/6/1 19:02

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


Did you setup the cron job to run per the instructions included with the module? You have to do that for it to run automatically. If I remember correctly, it also has a block you can use instead, but someone has to hit the block to make it call the file (note: the block doesn't actually display).

Clear as mud?
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

18
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/6/1 20:34

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


how do i do that? There are no clear instructions in the downloaded module!! How do i set it up to run automatically?? I thought just setting the number of days would do the trick!!!I dont think the block is the ideal way! I just want to run the sql statement once per day!
whttp://www.guidemap.gr - Beta is out...

19
kerkyra
Re: How to make a function similar to a cron job...
  • 2008/6/1 21:04

  • kerkyra

  • Just can't stay away

  • Posts: 553

  • Since: 2005/2/14


I have to set a cron job to run cron.php passing the password to run every day right?
whttp://www.guidemap.gr - Beta is out...

20
mboyden
Re: How to make a function similar to a cron job...
  • 2008/6/1 21:13

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


There is information in the help page of the admin side of the module. The cron job must be set to run:

modules/xoopscare/cron.php?password=mypassword

where mypassword is the password you assign in the preferences of the module.

You will have to work with your ISP to setup the cron job. Each ISP does it differently.
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

Login

Who's Online

464 user(s) are online (331 user(s) are browsing Support Forums)


Members: 0


Guests: 464


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits