Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


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):
    php yourscript.php
    So write this to a file called "yourscript.sh", and make it executable using this command:
    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


Copyright 1999 - 2012