performance - how to make a php automation background script for Windows and Unix? -


i have script creates thumbnails of larger images , works fine, problem is placed @ beginning of page both images viewed , understanding run every time visits page. doesn't seem performant.

i rather script have own page , somehow detected when more large images had been added directory scans , go work then.

how go setting or improving in someway?

found this, not sure how works. $cmd:

  /*i combined several efforts in topic 1 function:  execute $cmd in background (no cmd window)  without php waiting finish, on both windows , unix.*/     function execinbackground($cmd) {          if (substr(php_uname(), 0, 7) == "windows"){              pclose(popen("start /b ". $cmd, "r"));           }          else {              exec($cmd . " > /dev/null &");            }      }  

time base creation : perhaps (if have shell access), can create "cron job" :

in ''/etc/crond.d/'' create file :

0 6-18 * * *    root    /path/to/your/script.php >> /dev/null 2>&1 

it execute every hour 6.00 18.00.

see : http://en.wikipedia.org/wiki/cron more details.

automatic creation : if have "upload procedure", put "thumbnail generator" after uploading.

hook creation : indeed, depend of procedure use add new images in directory.

perhaps, can make hook execute script after updating dir.

but think first solution based on time (cron) easy implement.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -