Jump to content

Recommended Posts

Hi all.

 

I have a script that i want to run in a cronjob. but i dont know why it's not running.

i am using godaddy cpanel

 

ps: when i visit the url of the file, it works as expected, and also when i run it via a form button, it works also.

what could be the problem?

 

below is the command i used:

 

/usr/local/bin/php -q /home/username/directory/directory/file-name.php

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/
Share on other sites

What does the script do? Are there any errors logged? Is cron set up to email you the results?

 

The script is suppose to send a reminder to members. I don't think there's any error logged cos i didn't get any. Yes the cron is set up to send a mail to me but i got no mail as well.

Thanks

Link to comment
https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1522700
Share on other sites

You can log output like so:

/usr/local/bin/php -q /home/username/directory/directory/file-name.php >> /log/file/path.log
Make the path something that the CRON owner has write permissions to. Make sure that error reporting is turned on in the script.
Link to comment
https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1522712
Share on other sites

You can log output like so:

/usr/local/bin/php -q /home/username/directory/directory/file-name.php >> /log/file/path.log
Make the path something that the CRON owner has write permissions to. Make sure that error reporting is turned on in the script.

 

the cron owner has write permissions. was wondering maybe cron does not understand/cannot read sub-directory structure?

Link to comment
https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1522894
Share on other sites

Cron doesn't understand anything, it just executes the statements it is given at the specified intervals. If your command works when executed manually, it should also work when executed from a Cron job.

 

What I said about making sure the Cron owner has write permissions was specifically for the log file path that you add to the end of the command. The Cron owner would need write permissions for that log file.

Link to comment
https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1522915
Share on other sites

After setting my email to get the cron response, this is the error i got from the cron with my html messages:

 

Status: 302 Moved Temporarily
X-Powered-By: PHP/5.4.43
Set-Cookie: PHPSESSID=9aa0e1459caeb93365729438b3b12f54; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
location:./index.php
Content-type: text/html

Link to comment
https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1523325
Share on other sites

Those are headers, I see no error.

 

You said the script works when you visit from a browser, but does it work when you visit from the command line? Cron is not a browser, it uses command line programs.

 

Can you post your script?

Edited by scootstah
Link to comment
https://forums.phpfreaks.com/topic/298482-cronjob-wont-send/#findComment-1523377
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.