|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 Code:
php /httpdocs/admin/storage/testcron.php I got this error: No input file specified. Any thoughts?
__________________
Shazam! |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
||||
|
||||
|
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 |
|
#4
|
|||
|
|||
|
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. |
|
#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 |
|
#6
|
|||
|
|||
|
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. |
|
#7
|
||||
|
||||
|
Yeah, I tried that, too, but no dice.
|
|
#8
|
|||
|
|||
|
Quote:
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. |
|
#9
|
||||
|
||||
|
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! |
|
#10
|
|||
|
|||
|
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... |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > crontab/PHP problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|