The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 12 of 12

Thread: Cron-Job PHP

  1. #1

    Cron-Job PHP

    I have Cronjob but all the examples and tutorials I have looked at run .sh files, and I dont know what that is, (a linux file?) but I want to know how to run a PHP file using CronJob

  2. #2

  3. #3

  4. #4
    you might be able to have the .sh file visit the .php address. i don't really know anything about .sh files though.

  5. #5
    do you know what language it is written in?

  6. #6

  7. #7
    Cronjobs are commands that are run periodically. It is common to create a shell script that does what you want to happen for that purpose. These are the .sh files. Although they needn't necessarily have the .sh extension, it's good practice to name then .sh, so that people know it's a shell file.

    So for something as simple as executing a PHP script, your shell script might look like this, given that the path to your PHP binary is in your PATH (it likely is):
    Code:
    php yourscript.php
    So write this to a file called "yourscript.sh", and make it executable using this command:
    Code:
    chmod u+x yourscript.sh
    And then fill in yourscript.sh as the command to execute.
    Wait, what?

  8. #8

  9. #9
    I'm not sure if you need to use absolute paths or anything in the script for it to work. Before you enter the cronjob, place both the PHP and the shell scripts on the server and test it out by just executing the shell script to make sure it works and does what you expect it to do (you'll need to do the chmod command before you can execute it). If it does, go ahead and enter the cronjob.
    Wait, what?

  10. #10
    ahh, thank you ever so much

  11. #11
    No problem. Did it work out ok?
    Wait, what?

  12. #12
    well on my local test server it all works, havent tried it on my online one, but im sure its all set-up the same

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012