I have a cronjob which for creat thumbnails. the folder /var/www/html/work/ has permission 744(I think 744 is more safe than 777)
Crontabs
* * * * * /usr/bin/php /var/www/html/work/images.php
php script
$newstore = dirname(__FILE__) . '/images/.$data->name.'jpg';
$width = (int)($data->width);
$height = (int)($data->height);
$desired_width = round((300*$width)/$height);
$desired_height = 300;
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height);
imagejpeg($virtual_image,$newstore);
EDIT
In browser part. I have login into the phpmyadmin with root, So when I try localhost/work/images.php, it works well., and works in/usr/bin/php /var/www/html/work/images.phpinPuTTY SSH`.
but the job failed in crond. I have restart cron service crond restart all the thing [OK], then tried /etc/cron.allow, return -bash: /etc/cron.allow: No such file or directory, run /etc/cron.deny, return -bash: /etc/cron.deny: Permission denied.
BTY: vi /var/log/httpd/error_log there have no errors hint.
Where is the problem? crond setting? or folder permission?
/usr/bin/php /var/www/html/work/images.php, what error message do you get? I imagine that you're not able to write to the /var/www/html/images directory as the user you are running as. – cjc Jan 21 at 12:24chmod u+s /usr/bin/crontabandchmod u+s /usr/bin/php, now/usr/bin/php /var/www/html/work/images.phpcan work. but cron still not work. I have restart cronservice crond restartall the thing [OK], then tried/etc/cron.allow,-bash: /etc/cron.allow: No such file or directory, run/etc/cron.deny,-bash: /etc/cron.deny: Permission denied. So at this time, my problem is cron not excused. BTY:vi /var/log/httpd/error_logthere have no errors hint. Thanks. – yuli chika Jan 21 at 13:43/var/log/httpd/error_logis Apache error log - check your PHP error log. – faker Jan 21 at 15:20