Jump to content

Cron Jobs


L

Recommended Posts

I want to run a script every ten minutes for updating users online.

 

Can someone tell me how I can do this?

Last time I tried it gave me an server error so I'm afraid to try it out again.

The script includes files in the directory it will be in so is just the file name good for an include?

 

Thanks for your time,

~L

 

 

Link to comment
Share on other sites

take a look at these :

 

http://www.phpfreaks.com/forums/index.php/topic,175234.0.html

 

http://www.phpfreaks.com/forums/index.php/topic,175237.0.html

 

 

I would like to know as well, if you find  out, please post it here

thanks

 

if someone answers him you can check his thread to find out  ,so never post such a thing .

the reason i'm asking you about this is so many people when see a thread has a reply , do not read that thread , they search for threads with 0 replies, so you just decrease the chance of his thread to be answered . ( no offense)

Link to comment
Share on other sites

easy peasy, cron job isn't required for this. just a sec, I'll find the script I use.

 

EDIT:

script:

<?php
/*
* TG WHO'S ONLINE
* Copyright 2005 - 2006 (c) TOXIC GOBLIN
* http://www.toxicgoblin.com
* 
*/

//Optional Database Connection Information
//**Uncomment the following 2 lines and edit the values if you do not already have an active database connection**
//
//$db = mysql_connect("localhost", "username", "password") or die("Could not connect");
//mysql_select_db("database_name");

//Fetch Time
$timestamp = time();
$timeout = $timestamp - 900;

//Insert User
$insert = mysql_query("INSERT INTO TG_whos_online (timestamp, ip, file) VALUES('$timestamp','".$_SERVER['REMOTE_ADDR']."','".$_SERVER['PHP_SELF']."')") or die("Error in who's online insert query!");
//Delete Users
$delete = mysql_query("DELETE FROM TG_whos_online WHERE timestamp<$timeout") or die("Error in who's online delete query!");
//Fetch Users Online
$result = mysql_query("SELECT DISTINCT ip FROM TG_whos_online") or die("Error in who's online result query!");
$users = mysql_num_rows($result);

//Show Who's Online
if($users == 1) {
print("$users User Online.\n");
} else {
print("$users Users Online.\n");
}
?>

 

and here is the MySQL table you need setup:

/**

*

* TG WHO'S ONLINE

* Copyright 2005 - 2006 © TOXIC GOBLIN

* http://www.toxicgoblin.com

*

*/

 

/*

This is the database creation SQL. You will need to create this table in your MySQL database.

*/

 

CREATE TABLE `TG_whos_online` (

  `id` bigint(20) NOT NULL auto_increment,

  `timestamp` int(15) NOT NULL default '0',

  `ip` varchar(40) NOT NULL default '',

  `file` varchar(100) NOT NULL default '',

  PRIMARY KEY  (`id`),

  KEY `ip` (`ip`),

  KEY `file` (`file`),

  KEY `timestamp` (`timestamp`)

) TYPE=MyISAM;

 

Regards ACE

Link to comment
Share on other sites

Idk. I heard that you wouldn't want live stats because once the stats gets bigger it takes longer to load. For example a site my friend had had live stats, but it was so slow because it had over 700 members. So I just wanted to go the safe route with cron jobs, but last time I tried the server started messing up on me so I was wondering if someone knew how to do it correctly

 

Thanks for the threads!

 

Lastly, does the php file that is to be run need to be modified in anyway?

Like how would an include look like...would it just be normal?

Link to comment
Share on other sites

I have a online script, it tells when I am online, or any other user I set using my variables, and it also tells how many guest are online, and such

 

want it?

 

you can see it here: www.lamezz.com (in the top left corner)

and here: www.lamezz.com/user/viewmembers.php

Link to comment
Share on other sites

If it involves cron jobs, then I'd be glad to!

 

But I already have the script all made and everything...I just need an example of what an executable cron job script looks like so I can make sure no errors come up

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.