SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Location
    Texas
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with first cron job

    I'm trying to set up a cron job to run a PHP script ... I figured out this morning how to set up a crontab and everything, but - I can't seem to get it to run a PHP script.

    PHP is installed as an Apache module on my host's server (it's a shared hosting setup). Some tutorials on the subject recommend that if PHP is installed as an Apache module, you need to use lynx - but I guess my host doesn't have lynx because when I tried that it said lynx was not found.

    Here's what I have in my crontab file:

    Code:
    53 * * * * /path/to/crontest4.php%
    I've also tried:
    Code:
    53 * * * * php /path/to/crontest4.php%
    The error I get is:

    Code:
    Your "cron" job ... produced the following output:
    sh: /path/to/crontest4.php: not found
    ...or, in the second case:
    Code:
    Your "cron" job ... produced the following output:
    sh: php: not found

    The crontest4.php file is just a simple e-mail script:

    PHP Code:
    <?php
    mail
    ("me@mydomain.com""Cron Test""This is a cron test.""From: [email]crontest@mydomain.com[/email]");
    ?>
    Any suggestions? Thanks!

  2. #2
    SitePoint Guru enygmadae's Avatar
    Join Date
    Sep 2002
    Location
    Dallas, Tx.
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you're running it as a CGI like that you have to have the path in the top...

    PHP Code:
    #!/path/to/php
    <?php
    .....
    ?>
    that's why it says "not found".
    PHP News, Views and Community: http://www.phpdeveloper.org

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Location
    Texas
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This may be a dumb question, but how do I find out what is the path to PHP?

  4. #4
    SitePoint Guru enygmadae's Avatar
    Join Date
    Sep 2002
    Location
    Dallas, Tx.
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    either ask the admins (usually /usr/local/bin/php or /usr/bin/php) or you can try "which php" or whatever that command is to find it.....(unix).

    If you're on windows, you'll just have to ask.
    PHP News, Views and Community: http://www.phpdeveloper.org

  5. #5
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's with the "%" after .php? I find that running php scripts as crons when they have variables and such doesn't work on most hosts. I have several that have .php?this=that and have found that they always work if I just make a basic script that runs the script then run that as the cron. Such as runcron.php .

  6. #6
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    */5 * * * * /usr/bin/php /home/user/public_html//directory/cronphp.php is what I am using now and it works great.

    cronphp.php contains the include for the actual script with all it's variables.

  7. #7
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Location
    Texas
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I ran the "which php" command (it's a Solaris system) and the result was:

    no php in /usr/local/ssl/bin /usr/sbin /usr/lib/nis/bin /usr/openwin/bin /bin /usr/bin /usr/ucb
    /etc /opt/gnu_tools /usr/ccs/bin /opt/oracle/bin /usr/5bin /usr/local/bin

    I tried /usr/local/bin/php and /usr/bin/php but they don't work ...

    Oh, to answer Jump's question, the % is just a line break.

  8. #8
    SitePoint Guru enygmadae's Avatar
    Join Date
    Sep 2002
    Location
    Dallas, Tx.
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    then you'd just be better off looking on that host's support pages and seeing if they have the info there - otherwise, just email them. I know it's not the easiest way to do it, but it's the most reliable.

    If it's a system that has locate on it, you might also try "locate php" (but that'll only work if they have the files DB up to date..)
    PHP News, Views and Community: http://www.phpdeveloper.org

  9. #9
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Location
    Texas
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I opened a support case through their web-based system on Friday. They are really slow to respond, and often the person responding to you doesn't really know what they're talking about. But you're probably right, I will just have to wait on them.

    I tried locate but the system doesn't support it

    I've been looking for more info on the Internet and I'm wondering if it's even possible to run a php script from the command line if PHP is installed as an Apache module.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •