rantsh Posted May 23, 2007 Share Posted May 23, 2007 I have a php script that I need to run with crontab, now whenever I run the script from the command line by itself it runs fine, but when I have set it up as a cronjob it does not execute. I'm setting up the crontab with root and the script is (for library inclusion simplification issues) located in an apache public html directory. Can anyone help me figuring out why the cronjob is not being executed? PS: I tried adding a > /home/someLogFile.log at the end of the line in the cronjob so it'll create a file to be sure it's running and also the time when it ran, and the file was properly created at the expected time... Thanks in advance, rantsh Quote Link to comment https://forums.phpfreaks.com/topic/52646-crontab-for-root/ Share on other sites More sharing options...
trq Posted May 23, 2007 Share Posted May 23, 2007 Can we see the script and your crontab entry? Crontab itself only has a limitted environment so you need to use the full paths to executables. Quote Link to comment https://forums.phpfreaks.com/topic/52646-crontab-for-root/#findComment-259994 Share on other sites More sharing options...
rantsh Posted May 23, 2007 Author Share Posted May 23, 2007 the line in crontab looks something like this * * * * * /path_to_php_bin_directory/php /path_to_script/script.php script.php works fine if I use it straight in the command line but crontab doesn't seem to make it work. Crontab is supposed to have the same permits as the user who sets it up (root in my case), right?. Either way, I'm sorry I can't give you the real path but it looks very close to: /path_to_script/ = /srv/www/vhosts/xxx.com/httpdocs/app_folder/admin_only For the time being I've moved the script to /home where IT WORKS in crontab (don't know why it works there and not on the actual directory, but I'd like to know why it doesn't work. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/52646-crontab-for-root/#findComment-260084 Share on other sites More sharing options...
the_oliver Posted May 23, 2007 Share Posted May 23, 2007 If it works in home then it could be seLinux getting in the way. Are you running seLinux? Quote Link to comment https://forums.phpfreaks.com/topic/52646-crontab-for-root/#findComment-260322 Share on other sites More sharing options...
trq Posted May 24, 2007 Share Posted May 24, 2007 Crontab is supposed to have the same permits as the user who sets it up (root in my case), right?. Yes, it has the same perms, but a limited environment. eg No $PATH variable. Also... make sure your using the full paths to any includes in your script. Crontab will get confused by relative paths. Quote Link to comment https://forums.phpfreaks.com/topic/52646-crontab-for-root/#findComment-260652 Share on other sites More sharing options...
neylitalo Posted June 4, 2007 Share Posted June 4, 2007 I'm no expert, but I would be very surprised if * * * * * didn't break cron, or at least make it refuse to run the job. That, right there, is going to make it run that script every minute of every hour of every day of every week of every month. You may want to rethink your scheduling plan. Quote Link to comment https://forums.phpfreaks.com/topic/52646-crontab-for-root/#findComment-267879 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.