Can i create "Cron Jobs" myself to PHP code or is there any other way to do that, because i have own (homehosted) webserver where i would like to have Cron Job visit at the pages for execute action by visiting at the site?
Thanks.
Printable View
Can i create "Cron Jobs" myself to PHP code or is there any other way to do that, because i have own (homehosted) webserver where i would like to have Cron Job visit at the pages for execute action by visiting at the site?
Thanks.
like I said in the previous post you made (and I don't know why you bothered making a new thread for it), a cron job is something ran by your server itself. it has nothing to do with PHP. it's a way of making any command run on the system any number of times throughout the day, week, or month. and it just so happens that you can call PHP from the command line.
also like I mentioned in my other post, you're only going to be using cron jobs if you are using a Unix server. if you're actually running your own Unix server, I would hope you were confident enough in using your system to be able to figure out how to do it. if not, you could always google how to set up a cron job.
if you're not using a Unix server, then you're going to be using scheduled tasks in Windows. you can do a google search on how to create a scheduled task in a Windows environment if you need help.
in either environment, the command you need to run is:
windows:
php C:/path/to/my/file.php
unix:
php /path/to/my/file.php
My webhost supports cron job, but seems that the my webhost doesn't support connections to another places with fsockopen (it's enabled btw) if i put random gameserver IP and port it says online at my computer, but at my hosting place it says Offline.
EDIT: And i tought you meant cPanel and webhosting at some other place (in last thread)
um, what I said in the last thread and this thread above applies to servers in general. a unix server uses cron jobs (which can be changed via cPanel if your host has it installed), and a windows server uses scheduled tasks (which can probably be changed via whatever control panel they would have). if your host won't let you open connections to other servers, though, then that's a whole different issue.
if i get what you want to try then i guess you just want to update some content of your site without updating the whole site, this will be fsockopen. you could try using the same thing as facebook uses for updating their content, they refresh even if you don't refresh your browser...
Link, thats where i found the code...
now you create a file called loadcontent.php and in there you putCode:<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
{
$('#fsockopen').load('loadcontent.php').fadeIn("slow");
}, 300000); // 300000 = 5 min (milliseconds)
</script>
<body>
<div id="fsockopen">
<?php
$host = "192.168.1.13";
$port = "80";
@$socket = fsockopen($host, $port, $errno, $errstr, 5);
if(!$socket) {
echo "Offline";
} else {
fclose($socket);
echo "Online";
}
?>
</div>
</body>
Code:$host = "192.168.1.13";
$port = "80";
@$socket = fsockopen($host, $port, $errno, $errstr, 5);
if(!$socket) {
echo "Offline";
} else {
fclose($socket);
echo "Online";
}
The PHP page you're loading via AJAX is still using fsockopen(), which zeuz said his host won't allow; so it won't work.
I don't know if this would help?
You could use a service like http://www.cronwatch.com