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 > Developer Center > Cron paths

Cron paths
Thread Tools
Fresh-Faced Recruit
Join Date: May 2008
Status: Offline
Reply With Quote
May 18, 2008, 07:48 AM
 
I am sure this is very simple.
I have a script at
http://localhost:8888/process/testing/onetime.php
I want it to run as a cron job.

10 1 * * * /usr/bin/wget -q localhost:8888/process/testing/onetime.php

What is wrong with this.
Is there some path info missing or something else
Thanks
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 18, 2008, 11:27 AM
 
well, for starters it needs the http:// in front of localhost. I doubt that you have wget installed in /usr/bin, this is the Linux install path. Are you doing this on a Linux box? What happens when you run that command manually?
     
beedie  (op)
Fresh-Faced Recruit
Join Date: May 2008
Status: Offline
Reply With Quote
May 18, 2008, 12:46 PM
 
i have tried with http:// and failed but i haven't installed wget. How is that done?
I am on os x tiger ibook. Also I am using Mamp so directories are in Applications if that messes things up.
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 18, 2008, 01:12 PM
 
Why are you doing it that way anyway? Why not just execute it via the command line PHP interpreter?

what happens when you:

php /web/server/path/process/testing/onetime.php
     
beedie  (op)
Fresh-Faced Recruit
Join Date: May 2008
Status: Offline
Reply With Quote
May 18, 2008, 01:51 PM
 
I need it to recur. Maybe onetime isn't such a good file name. it was at the time!
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 18, 2008, 01:54 PM
 
I know you need it to recur, you can put that command in your crontab.
     
beedie  (op)
Fresh-Faced Recruit
Join Date: May 2008
Status: Offline
Reply With Quote
May 18, 2008, 10:58 PM
 
So this what is in my crontab:
Code:
# minute hour mday month wday who command 48 * * * * /usr/bin/php Applications/Mamp/htdocs/process/testing/onetime.php
I am changing the minute each time i try.
Something must be wrong with the syntax or Tiger now doesn't support it.
Should be a newline after command
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 18, 2008, 11:03 PM
 
The Applications needs a leading slash, but I think there might be a gap in your understanding...

All cron does is executes a particular command at a particular time interval. If that same command (/usr/bin/php Applications/Mamp/htdocs/process/testing/onetime.php) doesn't produce the desired output when invoked in the command line manually, it is not going to work as a cronjob.

So, again, what happens when you invoke it manually? There is no point in worrying about your cronjob if the command does not even work properly.
     
beedie  (op)
Fresh-Faced Recruit
Join Date: May 2008
Status: Offline
Reply With Quote
May 18, 2008, 11:45 PM
 
ok this has now worked from the command line

Code:
curl http://localhost/process/testing/onetime.php
this did not work in the crontab

Code:
49 * * * * curl http://localhost/process/testing/onetime.php
do i need to add a user?
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 18, 2008, 11:51 PM
 
No, my guess would be that your cronjob doesn't know the path to your curl command. Do a:

which curl

in your terminal and paste in the full path name to your cronjob, replacing "curl". Then shortly before the cronjob is to run, do a:

tail -f /var/log/system.log

in your Terminal, or else watch this output in your Console app (inside your Utilities folder). The object here is to look for whether or not your cronjob is dying because of a particular error. If it is, this error should be logged. Let me know if this is generating an error.

It is likely that adding the full path will get this working for you though. I have no idea what executing onetime.php is supposed to do, and why it needs the overhead of curl or wget rather than just executing it via the command line PHP interpreter, but whatever works...
     
beedie  (op)
Fresh-Faced Recruit
Join Date: May 2008
Status: Offline
Reply With Quote
May 19, 2008, 12:03 AM
 
This is what came in the Terminal


bob:/private/etc Bob$ tail -f /var/log/system.log
May 19 09:38:02 bob cp: error processing extended attributes: Operation not permitted
May 19 04:08:03 bob postfix/postqueue[541]: warning: Mail system is down -- accessing queue directly
May 19 09:38:03 bob cp: error processing extended attributes: Operation not permitted
May 19 09:47:14 bob sudo: Bob : TTY=ttyp1 ; PWD=/private/etc ; USER=root ; COMMAND=/usr/bin/nano crontab
May 19 10:13:31 bob sudo: Bob : TTY=ttyp1 ; PWD=/private/etc ; USER=root ; COMMAND=/usr/bin/nano crontab
May 19 10:22:03 bob sudo: Bob : TTY=ttyp1 ; PWD=/private/etc ; USER=root ; COMMAND=/usr/bin/nano crontab
May 19 10:24:28 bob sudo: Bob : TTY=ttyp1 ; PWD=/private/etc ; USER=root ; COMMAND=/usr/bin/nano crontab
May 19 10:28:28 bob sudo: Bob : TTY=ttyp1 ; PWD=/private/etc ; USER=root ; COMMAND=/usr/bin/nano crontab
     
beedie  (op)
Fresh-Faced Recruit
Join Date: May 2008
Status: Offline
Reply With Quote
May 19, 2008, 12:06 AM
 
the onetime file is generating thumbnails on my local server. i would be setting it fro regularly once i can get it to work. Slows down my site to do it on the fly
Hope that helps understand my situation
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
May 19, 2008, 12:17 AM
 
What time did your cronjob run? Anything that corresponds with those timestamps? Did it execute properly this time now that you added the full path to curl?

Once you get this to work, I would experiment with:

/path/to/php /path/to/process/testing/onetime.php

less overhead that way.
     
beedie  (op)
Fresh-Faced Recruit
Join Date: May 2008
Status: Offline
Reply With Quote
May 19, 2008, 12:25 AM
 
it did not execute even with the path to curl

Thsoe timestamps look like each of my attempts to get it to run

Also this doesn't work in the terminal

bob:/private/etc Bob$ /usr/bin/curl http://localhost/process/testing/onetime.php
curl: (7) couldn't connect to host
(Last edited by beedie; May 19, 2008 at 12:30 AM. (Reason:update))
     
beedie  (op)
Fresh-Faced Recruit
Join Date: May 2008
Status: Offline
Reply With Quote
May 19, 2008, 12:59 AM
 
Actually this does work

Code:
bob:/private/etc Bob$ /usr/bin/curl http://localhost:8888/process/testing/onetime.php
from the command line.
Thank you again for all your patience
     
beedie  (op)
Fresh-Faced Recruit
Join Date: May 2008
Status: Offline
Reply With Quote
May 19, 2008, 04:13 AM
 
rebuilding cron was never done

crontab /etc/crontab

was all that was needed.
Thanks for all your suggestions
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:41 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2