jmcc Posted July 8, 2010 Share Posted July 8, 2010 Hi Is there a way to automatically call a script every day. I want to send a information email out everyday at 6am, but don't want to go and click the send email button every day at 6 am. Thanks Jay Quote Link to comment Share on other sites More sharing options...
hardanro Posted July 8, 2010 Share Posted July 8, 2010 You need to use cronjobs. In you need to add an entry like: 0 6 * * * lynx -dump http://www.yoursite.com/sendmail.php (change http://www.yoursite.com/sendmail.php with the location of the script that sends the emails) Quote Link to comment Share on other sites More sharing options...
jmcc Posted July 8, 2010 Author Share Posted July 8, 2010 Hi Thank you for the reply. Where to I add the cronjobs code? Thanks, Jay Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 8, 2010 Share Posted July 8, 2010 Why use lynx? Just use the php cli: 0 6 * * * /path/to/php -q -f /full/path/to/your/file/sendmail.php You have to talk to your hosting service about how to set up cron jobs. Ken Quote Link to comment Share on other sites More sharing options...
hardanro Posted July 8, 2010 Share Posted July 8, 2010 The reason for choosing lynx is because runing the script in php-cli is not the same as runing the script in a browser : $_GET variables will not be available, include() will not work as when runing the script in the web broser, so runing the cron in command line can result in more headaches and script debuging. I agree that runing php cli is the better solution, but for simple tasks, or not wanting to change your script to run in cli mode, lynx could also be a solution. jmcc if you have cpanel you have should have an icon there to add cronjob. Click on it and add the details there. Quote Link to comment Share on other sites More sharing options...
jmcc Posted July 8, 2010 Author Share Posted July 8, 2010 So the cronjob is not a line of code in my script.php file? where must I insert this line of code? Thanks Jay Quote Link to comment Share on other sites More sharing options...
kumarkiranm Posted July 8, 2010 Share Posted July 8, 2010 type crontab -e at linux/unix command prompt type following code (replace path and filename as per your environment) 0 6 * * * /path/to/php -q -f /full/path/to/your/file/sendmail.php Save & Exit (Esc -> :wq) Quote Link to comment Share on other sites More sharing options...
jmcc Posted July 8, 2010 Author Share Posted July 8, 2010 Thank you for your help Quote Link to comment 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.