Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #4402

Re: Running function in the background?

From "M. Strobel" <sorry_no_mail_here@nowhere.dee>
Newsgroups comp.lang.php
Subject Re: Running function in the background?
Date 2012-01-10 17:39 +0100
Message-ID <9n37ucF7l8U1@mid.uni-berlin.de> (permalink)
References <jeg4fm02opn@news1.newsguy.com> <9n37aqF2t3U1@mid.uni-berlin.de>

Show all headers | View raw


Am 10.01.2012 17:29, schrieb M. Strobel:
> Am 10.01.2012 02:32, schrieb John Drako:
>> I have a site where users can download files, and I want to enable the 
>> users to request files by email. Some of those files are big (not too 
>> big for email attachements).
>>
>> What I would like to have the user be able to do is to click on a file 
>> and have it emailed to him, but the user shouldn't have to wait for the 
>> emailing function to finish (tens of seconds some time) and continue 
>> browsing and clicking on other files to email or even leave the site 
>> confident that they'll receive the files in their email later.
>>
>> So I would like the emailing functionality to happen in the background 
>> and independent from the connection to the browser.
>>
>> Is this possible? Is it doable in PHP directly?
>>
> Damn good question.
> 
> As to do it in PHP directly I find
> http://stackoverflow.com/questions/317392/is-process-forking-in-php-apache-a-good-idea
> with links to other questions of this type.
> 
> I never did forking in the web server because I consider it
> dangerous, it can kill or hang it or send it into a loop.
> 
> I did it like Mike suggested, with cron-jobs running every 10
> minutes, and even with my own daemon "watching" a job file. For
> shared hosting mostly not doable..
> 
> /Str.

Addition:

If the at command works okay in your server you can schedule jobs
in your script. I do it in a cgi script calling a shell script,
and this does

echo /usr/local/bin/webblock remove $2 | /usr/bin/at  now + 5
minutes 2>/dev/null

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Running function in the background? John Drako <jbravo556@gmail.removethis.com> - 2012-01-09 20:32 -0500
  Re: Running function in the background? Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-09 20:43 -0500
  Re: Running function in the background? The Natural Philosopher <tnp@invalid.invalid> - 2012-01-10 02:06 +0000
  Re: Running function in the background? Michael Joel <no@please.com> - 2012-01-09 21:50 -0500
    Re: Running function in the background? Luuk <Luuk@invalid.lan> - 2012-01-10 11:50 +0100
    Re: Running function in the background? Jerry Stuckle <jstucklex@attglobal.net> - 2012-01-10 07:52 -0500
  Re: Running function in the background? Captain Paralytic <paul_lautman@yahoo.com> - 2012-01-10 02:03 -0800
    Re: Running function in the background? John Drako <jbravo556@gmail.removethis.com> - 2012-01-11 08:40 -0500
  Re: Running function in the background? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-01-10 17:29 +0100
    Re: Running function in the background? "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-01-10 17:39 +0100

csiph-web