gerkintrigg Posted November 15, 2007 Share Posted November 15, 2007 Hi. I've managed to create a cron job to execute a perl cgi script on one server, but I'm now using a different server (they have cron too though) I wondered whether I'm able to do the same thing with a PHP script (for automatic newsletters... membership renewal notifications - that kind of thing.) If so... is it the same process? because it doesn't work when I set it... not only does it not do what the script should do, it also doesn't email me to say whether the cron has executed successfully or not. I wasn't sure whether it might be the fact that it's a PHP script or the different server that might be causing the problem. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
axiom82 Posted November 15, 2007 Share Posted November 15, 2007 The script is not executing. The new server either has a different version of cron or executes php from a different file path. I could be completely wrong though. Quote Link to comment Share on other sites More sharing options...
trq Posted November 15, 2007 Share Posted November 15, 2007 Cron is simply a task schedualer. Cron itself will not email you when it runs, alot of people get used to this feature through some control panel and assume its cron itself that send the email. Not so. Anyway, we need some details. How have you setup this cron job? Via crontab -e ? (ie; the command line), and if so, what does your crontab look like? Or, through some control panel? And even then, can we see the line that executes your script? Are you trying to execute a cli (command line interface) php script or do you expect it to run like a script called vai apache? The difference being the former will need a shebang line... eg; #!/usr/bin/php at the top, or will need to be called with the full path to the php executable within the crontab line... eg; /usr/bin/php /full/path/to/your/script.php The later will need to make a web request via cron. (Usually done with wget or curl) eg; /usr/bin/wget http://yourdomain.com/crons/script.php Also note that any filepaths used within your script will need to be absolute because cron has a very limited environment. Quote Link to comment Share on other sites More sharing options...
gerkintrigg Posted November 19, 2007 Author Share Posted November 19, 2007 thorpe - i think this may be the issue then. So when I set the cron - I add the full http:// path? That'd explain why i get the errors with my comment code (//) then - I presume... Quote Link to comment Share on other sites More sharing options...
trq Posted November 19, 2007 Share Posted November 19, 2007 http:// is not a path. Its a url. If you want to execute your script via apache you will need to use something like wget to call them. Otherwise, you'll want to set them up as cli scripts. I think my previous post explains things pretty well. 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.