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.
            Asked
            
        
        
            Active
            
        
            Viewed 106 times
        
    1
            
            
         
    
    
        kojiro
        
- 74,557
- 19
- 143
- 201
 
    
    
        Michael Ryden
        
- 33
- 1
- 5
- 
                    @kojiro is right - however, to answer the specific part of your question about running commands via php: http://php.net/manual/en/function.shell-exec.php – random_user_name Oct 04 '13 at 02:38
1 Answers
3
            
            
        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.
- 
                    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 Oct 04 '13 at 02:46
- 
                    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) – Michael Ryden Oct 04 '13 at 09:36
