Find the answer to your Linux question:
Results 1 to 5 of 5
Greetings, I'm playing with creating cronjobs, which are new to me. I have a php script that writes to a log file with some simple output. My php script works; ...
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Posts
    8

    [SOLVED] Call a php script from a cronjob

    Greetings,
    I'm playing with creating cronjobs, which are new to me. I have a php script that writes to a log file with some simple output. My php script works; I've tested that. I know the basics of adding a cronjob, but I can't get my php script to run from my cronjob. My php script is named: mylog.php.

    currently my cronjob looks like this:

    30 15 * * * /home/jdc/myfiles/mylog.php

    I'm thinking that I need to use the php command to run the php script. Can anyone let me know how to do this or tell me what I'm doing wrong?

    Thanks,
    JohnC

  2. #2
    Just Joined!
    Join Date
    Apr 2008
    Posts
    8
    Do cronjobs only run on a webserver? I'm not running a webserver, I'm only doing this on my laptop. A friend mentioned that she thought crons could only work when running on a server setup.

    Thanks

  3. #3
    Trusted Penguin elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    2,298
    You will need to have the php cli version installed and then call it with

    Code:
    php  /home/jdc/myfiles/mylog.php
    If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)


    My new blog. It's probably not as good as I think it is.

  4. #4
    Just Joined!
    Join Date
    Apr 2008
    Posts
    8
    Thank you,
    I actually figured this out just before I read your post. I'm not sure what you mean by the php "cli" (client?). But, it was the path to the mycron.php file. I needed the full path, as you posted.

    That lets my file run.

    Thanks again for the help.

    How do I mark these threads complete or resolved?

  5. #5
    Just Joined!
    Join Date
    Apr 2008
    Posts
    8
    sorry, I miss posted my file name. It is /home/jdc/myfiles/mylog.php. It works.

Posting Permissions

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