Jump to content

cron job to launch php page which send e-mail


09027882

Recommended Posts

I am building an online booking system for a project I am working on. i need to launch a webpage every day so that it can run a script which will check the dates of appointments, and send an e-mail to the given user 2 days in advance. From research on the internet it seems I need to use' cron'

 

 

 I have input a cron command to run every 5 minutes for testing purposes follows but nothing seems to happen

 

 
*/5 0 * * * php -f /home/a9645958/djtimbutterfield.hostzi.com/tteeth/mailtest.php
 
 
I know the mailtest.php page works as an e-mail is sent to the given -mail address when I execute it...
 
can someone please suggest where I am going wrong? I have not used this function before?
Link to comment
Share on other sites

I had this same issue a while back, what did the trick for me was to log if the web page was access at all  by the cron job. The other thing you might want to do is add /usr/bin/php or find out where the php is located at, in my case it was that.  

 

If i'm correct the command should look something like this 

 */5 0 ***  /usr/bin/php  /home/a9645958/djtimbutterfield.hostzi.com/tteeth/mailtest.php

Edited by svgmx5
Link to comment
Share on other sites

Did you try contacting them? maybe they can give you a little more help if that's the case. Because i know that a php script needs to have the path to where the php is located at on the server in order to execute properly. 

 

Other than that, good luck, hopefully you find a solution 

Link to comment
Share on other sites

Running a script in a cron job is not the same as accessing it through the browser. As a cron job, it does not go through the web-server so; the effective user is different (which can cause permission issues), the environment is different (which can cause includes to fail), the super globals ($_SERVER, $_GET, etc) are different or missing.

 

In a normal *nix system, any output from a cron job is automatically emailed to the user who scheduled it. In a shared hosting environment, I would guess this is the email address you registered with. Try adding error reporting to the top of the script. And see what is failing:

error_reporting(E_ALL);
ini_set('display_errors', 1);
If the output email doesn't work, you can log errors to a file, but you have to use an absolute path name (like you did for the script in the crontab).
Link to comment
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.