09027882 Posted March 21, 2013 Share Posted March 21, 2013 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? Quote Link to comment https://forums.phpfreaks.com/topic/275986-cron-job-to-launch-php-page-which-send-e-mail/ Share on other sites More sharing options...
svgmx5 Posted March 21, 2013 Share Posted March 21, 2013 (edited) 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 March 21, 2013 by svgmx5 Quote Link to comment https://forums.phpfreaks.com/topic/275986-cron-job-to-launch-php-page-which-send-e-mail/#findComment-1420195 Share on other sites More sharing options...
09027882 Posted March 21, 2013 Author Share Posted March 21, 2013 hmm I'm using a free server (000webhost) which only seems to allow the print -f command, it doesn't allow you to type the whole command, thanks for the reply though svgmx5 I'll have a root around! :-) Quote Link to comment https://forums.phpfreaks.com/topic/275986-cron-job-to-launch-php-page-which-send-e-mail/#findComment-1420206 Share on other sites More sharing options...
svgmx5 Posted March 21, 2013 Share Posted March 21, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/275986-cron-job-to-launch-php-page-which-send-e-mail/#findComment-1420214 Share on other sites More sharing options...
DavidAM Posted March 22, 2013 Share Posted March 22, 2013 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). Quote Link to comment https://forums.phpfreaks.com/topic/275986-cron-job-to-launch-php-page-which-send-e-mail/#findComment-1420372 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.