apsac Posted March 9, 2009 Share Posted March 9, 2009 Hi all, I am looking for a way for my site to do something in the background. I'm a relative beginner so bare with me... My site has a DB which stores stocks and their prices. This is updated every time the user logs in to find them the latest price. However, I want to add a function so that the user can say "If the stock reaches this price, do this (probably send an email or something)". I know of the mail() function so sending an email isn't a problem but since my DB is only updated when someone logs in, I'm struggling to get my head round how to do something when someone isn't loading the page. For example, someone might not log in for 2 weeks but in that 2 weeks I want the price to be checked to see if something should be done. It might not even be a PHP solution but was wondering if anyone had a good direction to head in. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/148633-solved-how-to-do-things-in-the-background/ Share on other sites More sharing options...
Mark Baker Posted March 9, 2009 Share Posted March 9, 2009 Look at using cron jobs if you want to check or run tasks on a regular, scheduled basis Quote Link to comment https://forums.phpfreaks.com/topic/148633-solved-how-to-do-things-in-the-background/#findComment-780509 Share on other sites More sharing options...
apsac Posted March 9, 2009 Author Share Posted March 9, 2009 Thanks, looks like a promising solution however, from what I have just read, is it likely I will be able to do this if I am not using my own server (I am a student doing a project and hence it is hosted on my uni servers) Quote Link to comment https://forums.phpfreaks.com/topic/148633-solved-how-to-do-things-in-the-background/#findComment-780513 Share on other sites More sharing options...
Maq Posted March 9, 2009 Share Posted March 9, 2009 Why don't you try? For linux use the crontab, for windows use scheduled tasks. Assuming they're linux servers, this looks like a decent tutorial: cron jobs. Quote Link to comment https://forums.phpfreaks.com/topic/148633-solved-how-to-do-things-in-the-background/#findComment-780521 Share on other sites More sharing options...
apsac Posted March 9, 2009 Author Share Posted March 9, 2009 Yeah they are linux servers but the thing is I don't understand how I try...? It looks like a command line thing, how do I implement that? Sorry if I'm being completely thick here... Quote Link to comment https://forums.phpfreaks.com/topic/148633-solved-how-to-do-things-in-the-background/#findComment-780531 Share on other sites More sharing options...
Maq Posted March 9, 2009 Share Posted March 9, 2009 If you're in school, they may only allow root to edit the crontab but you can still try follow the tutorial, you go into the console and type in "crontab -e" to edit the cron tab. Then you have to read the tutorial for the time format, and you just give it the path for the script you want to run. Quote Link to comment https://forums.phpfreaks.com/topic/148633-solved-how-to-do-things-in-the-background/#findComment-780535 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.