Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > How can I launch php using cron

How can I launch php using cron
Thread Tools
bigfatdoug
Fresh-Faced Recruit
Join Date: Jun 2005
Status: Offline
Reply With Quote
Jun 21, 2005, 09:54 AM
 
Hi,

I'm trying to launch a php script every hour but not getting much success.

I've edited crontab OK and made it simply use osascript to 'say' something. That worked OK.

I can also call the following shell script manually from the terminal and that triggers my PHP script.

#!/bin/sh
cd /Users/Me
/usr/bin/php sync.php --update --expire

But I can't make it work so that the crontab calls the shell script which triggers the PHP.

I can't figure it out. Do the scripts have to be in specific places to work? Is it a permissions thing?

Any help would be appreciated.

Thanks.
     
ctlq
Junior Member
Join Date: Nov 2004
Location: Michigan
Status: Offline
Reply With Quote
Jun 21, 2005, 12:52 PM
 
It could be a permissions thing depending on your setup but you can figure that one out easy enough by adding it to the root crontab. It looks like though, you aren't specifying the full path to the script.

your crontab entries can either look like this:
0 5 * * * /usr/bin/php /web/unified/download.php
or like this:
0 5 * * * /web/unified/download.php

For the latter to work you need to add this line to the top of your php file:
#!/usr/bin/php

(note: your php path my differ)
     
bigfatdoug  (op)
Fresh-Faced Recruit
Join Date: Jun 2005
Status: Offline
Reply With Quote
Jun 22, 2005, 06:55 AM
 
Thanks for the reply.

All working now although I have a suspicion that part of the problem was my cron table suffering after too many edits. In the end I reverted to a saved version, applied my changes and it worked. It also seems that playing with the system clock - eg. setting it to just before the cron job is due, means the script fails to run sometimes. Restart sorts it out though.

Thanks again.
     
   
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 01:43 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,