I tried everything since yesterday up to now, but, unfortunatly, I could not solve this problem. The one I describe below:
Let's go:
1 - I have a DIR on server where its generated some files. So I did a script (PHP) to read those files and do some actions. No big deal until now. This action works pefectly when executed as browser's link. This was the first step to avoid any stupid mistakes when cron is aplied.
2 - I read a bunch of informations related to CRON. I have ROOT access and I used: "crontab -e" command to make things "up".
3 - I will inform below in order of atitudes done (so hard for something apparently simple) so all of you can keep track of my steps:
3.1 - Runing crontab -e:
(3) The php file has the following config in the first line:
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
*/1 * * * * root php "path to my php file" >> "path to the log file" 2>&1
(1) The user is root. Note either that cron will run every minute to fit my needs.
(2) I was using, before this, a third file (sh) : instead of "path to my php file" I was using: "path to sh file [and this file calls the php file]". Of course, in time, that all these files have CHMOD "+x" applied.
Code: Select all
#!/usr/bin/php -q4 But, when the cron it s requested nothing happen to the file but generates the following log error: /bin/sh: root: command not found.
RESEARCHES
===========
I did a lot of researchs around. One of the most importants stated that to make use of : #!/usr/bin/php -q - php must run in CGI mode on LINUX. That s not my case. My dist run as APACHE HANDLER. I try to call LYNX or WGET there on CRONTAB but with no success. But, I call the file (php file) on terminal like: lynx http://www.mysite.com/myfile.php - everything works properly! Or if I use ./myphpfile.php - it s executed the same with success. But with CRON - no deal!
That's all! I hope, sincerelly, someone could help me!
Luyz