Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  agyat : (24 May 2013 - 05:15 PM) O Dear, Where Are You? Without Your Words This Sb Is ..
@  agyat : (23 May 2013 - 01:23 AM) Wow! Mr. Sb Back Home.
@  OpaQue : (23 May 2013 - 12:44 AM) Ting
@  OpaQue : (24 April 2013 - 02:44 PM) I guess, Time to run Mycent script.
@  OpaQue : (24 April 2013 - 02:43 PM) wow.. not much spam. except habatt posting lot of links.. :P
@  yordan : (23 April 2013 - 01:04 PM) You're welcome, agyat. Nice to have been helpful. Second lesson: try full words, "you" instead of "EW".
@  agyat : (23 April 2013 - 05:03 AM) @YORDAN: tHANK EW FOR YOUR FIRST LESSON.   :D
@  yordan : (22 April 2013 - 09:43 PM) @agyat : "why don't you help me", or "please help me", or "please teach us"
@  yordan : (22 April 2013 - 09:42 PM) welcome back, velma
@  velma : (22 April 2013 - 07:51 AM) **yawns** Good to be back, wonder what is going on here :)
@  agyat : (22 April 2013 - 03:50 AM) Oh! so, why don't help me learn english..
@  yordan : (21 April 2013 - 08:38 PM) The goal mentioned by shiu : "learning english, learning computer"
@  agyat : (21 April 2013 - 06:31 PM) WHAT GOAL?
@  yordan : (20 April 2013 - 10:39 AM) yes, that's our goal. simultaneouly learning English and teaching/learning computer using.
@  shiyu : (20 April 2013 - 07:30 AM) learning english,learning computer
@  yordan : (19 April 2013 - 01:11 PM) Oh, I see, it's just a trick in order to force people looking at your texte. Somehow smart, maybe.
@  agyat : (19 April 2013 - 02:54 AM) And of course I know it is not SEO friendly.
@  agyat : (19 April 2013 - 02:52 AM) There may be two possible answers for that ....


1) Shout was posted using mobile keypad.

2) To force people read content carefully and/or with more concentration.
@  agyat : (19 April 2013 - 02:49 AM) There may be two possible answers for that ....
@  yordan : (18 April 2013 - 09:35 PM) however, why this mixing of capital letters in the middle of your text?

Replying to Make A Script Run Even If No User Is Online


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

faulty.lee

Posted 17 March 2008 - 04:14 PM

Just curious, but is there a particular reason you don't want to use a cron job? Using php for maintenance without user interaction might be tricky since usually it only runs when a user is accessing the site. however if their is a significant reason that you dont want to or can't use a cron job then I can see why it'd be worth looking into.


There're cases where we run windows server, which doesn't have cron job. I would always use cron job on linux machine. Some hosting might not provide access to cron job.

Jeigh

Posted 17 March 2008 - 02:06 PM

Just curious, but is there a particular reason you don't want to use a cron job? Using php for maintenance without user interaction might be tricky since usually it only runs when a user is accessing the site. however if their is a significant reason that you dont want to or can't use a cron job then I can see why it'd be worth looking into.

faulty.lee

Posted 17 March 2008 - 01:44 PM

Forgotten to mention the less reliable ways.

1. Use http://www.webcron.o...ex.php?&lang=en. It wil lcall your URL/script at the preset time

2. Do the same as webcron, but from your own pc, or someone else pc which is one 24/7, using either schedule task or cron if you're running linux

3. Make the script intelligent, and call it from every link possible from your website, or from ajax scripted on our client side. You need to keep track of the execution of the script, so it will skip when it doesn't need to be run. Your site will need to have certain amount of traffic in order to use this method, and if not done properly, it will bog down the server. Also, it doesn't guarantee execution of the script at exactly the right timing.

I don't recommend using any of these methods, unless you really have no choice, especially the 3rd one.

faulty.lee

Posted 17 March 2008 - 01:31 PM

Is cronjobs the only solution?


More or less, cron job is the only reliable solution. I've came across this before when I was developing a web based hotel management software, where I need to charge each room with daily charges pass midnight. The only way to guarantee that it's charge, or the code to charge runs properly and on time is by using cron. Of cause this is only for linux based machine or server.

If you're running a windows server or running on your local windows machine, you can use Schedule Task, and set the script to recurring. The only set back is that you need to start the task manually for the first time if you happen to restart your pc. I do not know of any other workaround for that, so I wrote a .Net System Service, which runs in the background and check for schedule to run, much like cron, and it will run even without login.

For cron, you can refer to -> http://en.wikipedia.org/wiki/Cron

Cron is the service that execute the scheduled task, while you need use crontab to add/edit/remove the tasks from cron.

If you're referring to astahost' hosting, you can access "Cron Jobs" from cpanel. Choose standard, the rest is quite straight forward.

The command, you can either call php and pass the path to the script, or for my case I use wget, which fetch the output from an URL. So I wrote my script to output some status or response, wget will fetch it, and from the command, I redirect the output to a log file. That way I can easily keep track of the output. For cpanel, you can also choose to have the output send to your email address. But I would rather choose to check back from time to time instead of having my mail box filled up with logs(my script needs to be run every minutes).
wget -q -O- http://login.astahost.com/myscript.php >> /home/login/log/script.log
More or less like that, I can't remember the exact command. Anyway, I chose to use wget instead of php(commandline version), due to the fact that my script can't run properly in commandline, can't figure out what's wrong, so I chose the easier method.

Feelay

Posted 17 March 2008 - 11:14 AM

Is cronjobs the only solution?

and I have tried the query you gave me. But then, when I want to make every users hp to maxhp, everyone gets the highest maxhp in the table..

wutske

Posted 17 March 2008 - 10:38 AM

About the query, you have to do this:
SELECT maxhp FROM users

This returns a list with all the maxhp's from every user in the database. You can run through this list using while or foreach.
Check out example #2 here:http://us2.php.net/mysql_query

Your first problem can be solved using cron-jobs, but I've never used them so I don't know how you can configure them :) .

Feelay

Posted 17 March 2008 - 09:20 AM

Hey! Is there any way to make a script run, even if no user is online. Because at the moment, my scripts run, only when a user is online.

And another thing:
How can i make the following:
(this is just an example)
mysql_query"SELECT maxhp FROM users WHERE username = 'allusers'";
How can I select all users maxhp, in the same query?


Thanks //Feelay

Review the complete topic (launches new window)