I have a command line that I run from a specific directory to resize images, but I now need it to run from a php script so I can put it into a cron job to automate. The command is mogrify -resize 800x800\> *.jpg. I'm only looking for help to set up the php script, as I'm novice to doing this. Thanks in advance.
-
@kojiro is right - however, to answer the specific part of your question about running commands via php: php.net/manual/en/function.shell-exec.phprandom_user_name– random_user_name2013-10-04 02:38:28 +00:00Commented Oct 4, 2013 at 2:38
Add a comment
|
1 Answer
Cron has nothing to do with php. Have you tried putting
cd "$whatever_directory" && mogrify -resize 800x800\> *.jpg
in cron?
That said, you can get php to execute shell commands with exec and shell_exec, but I would urge you to consider if that's what you want.
2 Comments
Michael Ryden
I'm very new to doing even a basic script in php, so thank you for your response. ...and yes, I should have been a little clearer, I meant that this php script will later be put into a cron job. I will try your suggestion. Thanks
Michael Ryden
I'm glad I re-read your response to enter the code directly into cron. WORKED PERFECT and easier than expected! Thanks! I guess I didn't need to setup a php script file to call from. I am using ImageMagick on my server to process these images (I also had a misspelling: mogrify is the correct command wording I needed too)