UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 26th, 2005, 10:48 AM
shazam-fu's Avatar
shazam-fu shazam-fu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 158 shazam-fu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 39 m 45 sec
Reputation Power: 5
crontab/PHP problem

Hi,
I've been trying to use crontab to run a php script. I got a lot of useful info from past posts but my script still won't execute.

I have cron set to execute a shell script every minute (for testing). The script contains the following:
Code:
#!/bin/bash 
/usr/bin/php /httpdocs/admin/storage/testcron.php


I tried running this from the command line:
Code:
/usr/bin/php /httpdocs/admin/storage/testcron.php
and I tried this:
Code:
php /httpdocs/admin/storage/testcron.php

I got this error:
No input file specified.

Any thoughts?
__________________
Shazam!

Reply With Quote
  #2  
Old July 26th, 2005, 11:01 AM
shazam-fu's Avatar
shazam-fu shazam-fu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 158 shazam-fu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 39 m 45 sec
Reputation Power: 5
Nevermind. I had originally posted this problem in the PHP forum because I was getting a different error that seemed more PHP related but now it's resolved.

For anyone w/ the same problem, I just added -f after the php command & now it works!

So...

Code:
php -f /httpdocs/admin/storage/testcron.php

Reply With Quote
  #3  
Old July 26th, 2005, 11:30 AM
shazam-fu's Avatar
shazam-fu shazam-fu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 158 shazam-fu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 39 m 45 sec
Reputation Power: 5
Well, it only works from the command line.

It still isn't running from the shell script, though. My host has a Plesk control panel that has a pretty easy interface for setting up cron jobs so I don't know what the problem could be now.

I did change the code in my shell script to
Code:
php -f /httpdocs/admin/storage/testcron.php

Reply With Quote
  #4  
Old July 26th, 2005, 11:49 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
Cron has got its own search path settings. You should use the full path to the php binary.
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #5  
Old July 26th, 2005, 02:15 PM
shazam-fu's Avatar
shazam-fu shazam-fu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 158 shazam-fu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 39 m 45 sec
Reputation Power: 5
I was using /usr/bin/php but that didn't work either. I just tried using plain php because some people suggested it.

The only thing that seemed to work (from the command line only) was
Code:
php -f /httpdocs/admin/storage/testcron.php


I'm having cron execute a shell script w/ the following command but it doesn't work:
Code:
/usr/bin/php /httpdocs/admin/storage/testcron.php

Reply With Quote
  #6  
Old July 26th, 2005, 02:24 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
How about this:
/usr/bin/php -f /httpdocs/admin/storage/testcron.php

Anyways, are you sure php is in /usr/bin? Also, what kind of server is this. If you are on a shared host, your ISP might prevent you from doing this. A chroot() environment may cause problems too because your PHP interpreter may not be present inside.

Maybe this helps:
You can call PHP scripts also indirectly via Apache. In your cron script, start "lynx http://www.domain.tld/cronscript.php > /dev/null"

M.

Reply With Quote
  #7  
Old July 27th, 2005, 08:11 AM
shazam-fu's Avatar
shazam-fu shazam-fu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 158 shazam-fu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 39 m 45 sec
Reputation Power: 5
Yeah, I tried that, too, but no dice.

Reply With Quote
  #8  
Old July 27th, 2005, 02:17 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
Quote:
Originally Posted by shazam-fu
Yeah, I tried that, too, but no dice.

Hmmm. I forgot the question mark, but this was meant as one. An important one:
> Also, what kind of server is this?
ISP? Ensim maybe? Which system / control panel?

M.

Reply With Quote
  #9  
Old July 28th, 2005, 07:55 AM
shazam-fu's Avatar
shazam-fu shazam-fu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 158 shazam-fu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 39 m 45 sec
Reputation Power: 5
The control panel is Plesk. The OS is Linux.

But that's all I know. I'm not sure what type of server it is. I don't have direct access to the host - or even the shell for that matter! I have to call or email someone and tell them exactly what to type in the shell & have them email me the results in order to debug. Or I have to email them a question to ask the host.

It's a crazy way to debug & is taking about 100 times longer than it would if I could just get into the shell myself!

Reply With Quote
  #10  
Old July 28th, 2005, 09:30 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 42 m 50 sec
Reputation Power: 184
Never worked with Plesk.
Why I was asking... Maybe your server is running in a chroot environment. You can not access any programs not explicitly allowed by your host.
You can make some tests, eg. find the current path name with getcwd() when running php. If it does not contain any numeric scheme or similar ("/home/user123/htdocs" eg), you are probably in a chroot.

You could try to use the system() and similar functions to locate the php interpreter. eg.
passthru("find / -name php");

But then, maybe you should switch to a more flexible provider...
Comments on this post
Arty Ziff agrees: OUTSTANDING!

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > crontab/PHP problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT