Jump to content

Is there a way to queue system commands..


cgm225

Recommended Posts

Thank you for your help.  I read the php manual, but wanted to know if you could you help me with an example?

 

Let's say I want to run the followin command five times..

 

system("convert $photos_server_path/photos/$album/$buffer$number.jpg -resize 250x -gravity center -quality 100 -crop 250x141+0+0 $photos_server_path/photos/$album/thumbnails/small_thumbnail-$number.jpg");

 

..how would I do that by forking the process?  Also, if someone is running the script, what happens if they refresh the page, will the same command get sent again?

 

Thank you so much.

 

cgm225

Link to comment
Share on other sites

Thank you for your help.  I read the php manual, but wanted to know if you could you help me with an example?

 

Not at the moment; however, there's an in-depth introduction here that will probably do a better job.

 

Also, if someone is running the script, what happens if they refresh the page, will the same command get sent again?

 

I would assume this to be the same thing as an abort, but I'm not sure of all the logistics. Take a look at Connection Handling.

Link to comment
Share on other sites

The process control functions shouldn't be used within a web server environment.

 

Good catch.

 

is there a way to "queue" those system commands on the server somehow and allow the script to move on

 

What kind of processing are you doing that you need to move on before/while these other commands are processed?

Link to comment
Share on other sites

It looks like he's running a command that resizes images, probably to thumbnails.

 

On *nix you can direct the output of the command to /dev/null and it will execute without holding up your PHP script.  Although I sort of have to wonder why you'd want to do that with an image resizing command; granted there are a lot of variables but the one my application runs is very fast.

Link to comment
Share on other sites

It looks like he's running a command that resizes images, probably to thumbnails.

 

On *nix you can direct the output of the command to /dev/null and it will execute without holding up your PHP script.  Although I sort of have to wonder why you'd want to do that with an image resizing command; granted there are a lot of variables but the one my application runs is very fast.

 

If so, the images could be large... I have been using ImageMagick recently to process images that are 24,000px by 18,000px - It took my machine about 30 minutes to resize the thing!

Link to comment
Share on other sites

From system:

 

Note: If you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.