Yet it runs just fine through the browser. The file runs properly on cron, but the permission denied errors are given when the files are trying to be deleted (the script deletes files/folders in a given directory). I even changed all files and folders to 777 and I still get the errors when it runs on a cron job. What am I missing?
My first thought is that the user the cron job is running as doesn't have permission to create/delete files in the path.
dgreenhouse, Your theory makes sense as I remember having an issue months back with a cron job running as 'nobody" and having problems. I abandoned that project and never resolved it. How do I have the cron job run as a different user?
The easy way is to login as that user via SSH and edit that user's crontab. crontab -e Code (markup): Or, if you're a superuser. crontab -u username -e Code (markup):
Eeks, I have only used CPanel and WHM so far, is there someway using that or do I have to use SSH? Looks like I may need to read up a bit on this.
It's always wise to have SSH; if it's available... Makes life easier for these types of issues. Also, you can discuss it with the tech support dept. of your hosting company. They may very well have a solution for you.
I'm assuming I have superadmin rights as this is a VPS I have recently purchased, and I am sure learning a whole lot which I didn't need to know before. I'm assuming the "root" user is the superadmin? If so, how would I create a new user to run this cron job as I probably don't want to change the config for "nobody" for security reasons. I have remoted into SSH before so i will attempt this.
ok, I feel stupid but I need more help. I am using SSH through Parallels Power Panel and I can do the command "crontab -e" and it lists the running crontabs, BUT I don't know how to add a new one. After the listing, my cursor is right on top of the first line. Is there simple commands I am missing, or should I use a different SSH program?
Now I see, crontab is a file and the -e is to edit it. Now I have to figure out how to save the edit.
Ok I am a lot closer now, I have had some time to learn the shell commands. But now I have this issue, and I think it may be a directory issue between root and other users. * * * * * /usr/bin/php /home/sites/public_html/mysite.com/file.php This above line works for a user when setup in cpanel/cron program, but NOT with the root crontab file edited. It's the same exact line, yet the messages I am getting are 404 errors. Does the root directory have a different file structure than other users?
I should make it clearer that the email messages I receive on the cronrun when using the root crontab are: Status: 404 Not Found X-Powered-By: PHP/5.2.16 Content-type: text/html No input file specified. It works just fine when added to another users cron, but that is also using Cpanel to edit it.
I'm about ready to throw my laptop as far as I can... I have been messing with this for over a week now. What is the difference between "/usr/bin/php" and "/usr/bin/php -q" ??
ok, I am going to start a new thread with this issue, but I think I found the problem. These files/folders trying to be deleted are created by Apache with the user of "nobody".