Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 14th March 2007, 20:14
md@waw.co.uk md@waw.co.uk is offline
Junior Member
 
Join Date: May 2006
Posts: 24
Thanks: 2
Thanked 1 Time in 1 Post
Default add cronjob to run a page on a website

I understand that to add a cronjob I use crontab -e

I want to send emails to customers once a day, I have the page set-up & if I open the page in a web browser it works.

the path is /home/www/web(number)/web/auto/mail.php

I added this to the crontab

00 01 * * * /home/www/web(number)/web/auto/mail.php &> /dev/null

I think this will run at 1am every day - but it doesn't work.

Can you tell me where I'm going wrong please.

I have set CHMOD to 777 for the file mail.php

Thanks
Reply With Quote
Sponsored Links
  #2  
Old 14th March 2007, 21:10
ibux ibux is offline
Junior Member
 
Join Date: Dec 2006
Location: Oslo, Norway
Posts: 4
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by md@waw.co.uk
00 01 * * * /home/www/web(number)/web/auto/mail.php &> /dev/null
When running a PHP script from cron, you must run it through the php binary. When you view a PHP script in your web browser, the web server hosting the PHP file does that for you automagically.

So to run your cron job, do something like this:
Code:
00 01 * * * /path/to/php /home/www/web(number)/web/auto/mail.php
Hope that helps!
Reply With Quote
  #3  
Old 14th March 2007, 22:26
todgerme todgerme is offline
Member
 
Join Date: Dec 2005
Location: Belfast, Northern Ireland
Posts: 54
Thanks: 0
Thanked 1 Time in 1 Post
Default

you can also run a php file in lynx:

/usr/bin/lynx [-auth user : pass] -dump -source http://domain.com/somescript.php 2>&1 > /dev/null

the bit in []'s is optional and depends if your script is behind some sort of authentication
Reply With Quote
  #4  
Old 15th March 2007, 08:56
ibux ibux is offline
Junior Member
 
Join Date: Dec 2006
Location: Oslo, Norway
Posts: 4
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You will definitely want to add some kind of access control to that mail script.
Use a .htaccess file in the directory to block out unauthorized users. That won't affect scripts run from a cron job or shell.

Good luck.
Reply With Quote
  #5  
Old 18th March 2007, 18:11
md@waw.co.uk md@waw.co.uk is offline
Junior Member
 
Join Date: May 2006
Posts: 24
Thanks: 2
Thanked 1 Time in 1 Post
Default Thanks

Thank you

I've made the suggested changes & hopefully that will sort it out.
Reply With Quote
  #6  
Old 22nd March 2007, 23:12
mackenga mackenga is offline
Junior Member
 
Join Date: Mar 2007
Location: Glasgow, Scotland
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

If you wanted to use a cron job to hit a page via the web server, I wouldn't use lynx - lynx is great for interactive use but for this sort of thing I'd go with curl or wget.

Just my 2 cents.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Default Holding Page mphayesuk General 13 7th July 2007 16:25
getting shared IP page instead of website andyreynolds Installation/Configuration 12 6th March 2007 17:42
not seeing shared IP page andyreynolds Installation/Configuration 2 21st February 2007 23:24
Default page for new website.. mrdek11 General 3 7th February 2007 19:21
Website disabled with custom page and redirect. Herbert Feature Requests 3 7th August 2006 13:26


All times are GMT +2. The time now is 17:28.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.