I am using crontab to execute a PHP script to delete files and the directory after the files have been deleted. I keep getting permission denied when using the unlink command on the files.
Here is the PHP Script I am running.
The files are JPG images upload using PHP. The file permissions are 0644 user and group are 99. The directory itself is 777 user and group is 99 as well.Code:function RemoveDirectory($dirname) { if (!file_exists($dirname)) { return false; } if (is_file($dirname) || is_link($dirname)) { return unlink($dirname); } $dir = dir($dirname); while (false !== $entry = $dir->read()) { if ($entry == '.' || $entry == '..') { continue; } RemoveDirectory($dirname . DIRECTORY_SEPARATOR . $entry); } $dir->close(); return rmdir($dirname); } $dirName = 123; if (is_dir('/home/xxx/public_html/library/'.$dirName)) { RemoveDirectory('/home/xxx/public_html/library/'.$dirName); }
How do I give access to crontab to run this script and delete the files and directory?
If I run the script myself directly with the CMS I am using - no problems. Which means there is a permissions issue somewhere that needs to be fixed.
Any help appreciated. Thanks.



LinkBack URL
About LinkBacks
Reply With Quote





