Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/52646-crontab-for-root/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/52646-crontab-for-root/#findComment-260084
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/52646-crontab-for-root/#findComment-260652
Share on other sites

  • 2 weeks later...

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.

Link to comment
https://forums.phpfreaks.com/topic/52646-crontab-for-root/#findComment-267879
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.