Cron job on Debian 6
Hi all,
I am having a hard time to run a cron job in Debian 6. Basically i have a sample php script test.php that just adds a line of string(on every execution) to a text file named people.txt Both test.php and people.txt are located on my Apache document root /var/www directory. The script works fine standalone, but when i want to execute it every minute (for example) through a Cron Job it does not work. I setup a Cron Job as a root user, so when i run "crontab -e" as root user i see this line on Nano */1 * * * * /var/www/test.php when i run /etc/init.d/cron status i see message 'cron is running' But my people.txt file is not getting updated Any advise on how to make Cron Jobs run on my system? Thanks, Hayk |
Quote:
Code:
*/1 * * * * php -f /var/www/test.php |
I did not have shebang in my script.
Added the above parameters to crontab entry, restarted the cron, but still no change. Standalone the script runs just fine. Maybe the problem is with the cron in the system and not with this particular script? Any steps you would suggest to debug? Thanks, Hayk |
I'd check /var/log/cron (or the equiv on your system), but its the case that the env given to cron jobs is minimal hence its recommended to specify full/absolute pathnames for cmds & data files used.
You could post the script content if you want |
I checked /var/log/syslog and i see these lines related to cron
Quote:
Here is my php script: Quote:
Thanks, Hayk |
Hi,
as already mentioned you should specify full paths to files. EG Code:
<?php |
Thanks Evo,
Adding the absolute path fixed the issue and the cron job works fine. If i want to have my test.php script outside Apache document root directory (for example in my home directory /home/haykz) what should i change in the Crontab entry? Thanks again for all the help. Hayk |
Hi,
Quote:
Quote:
Code:
*/1 * * * * php -f /home/haykz/test.php Evo2. |
It worked just fine!
Thanks for all the help. Hayk |
All times are GMT -5. The time now is 01:29 PM. |