+ Reply to Thread
Results 1 to 9 of 9

Thread: Cron trouble

  1. #1
    kbjradmin's Avatar
    kbjradmin is offline x10 Elder kbjradmin is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Washington State, USA
    Posts
    512

    Cron trouble

    i guess this sort of goes in programming help, if not, please just move it.

    i am trying to set up a php script to run automatically each day using cron, but i can't seem to get it to work. i have it running the command:
    Code:
    cd /home/kbjr/cron && /usr/bin/php -q cleanPackages.php
    with the time settings:
    Code:
    3	0	*	*	*
    i don't use cron very often, so it's probably just something small and stupid, but i can't figure out what's wrong with it.

    please help, and thanks in advance

  2. #2
    dlukin is offline x10 Lieutenant dlukin is on a distinguished road
    Join Date
    Oct 2009
    Posts
    427

    Re: Cron trouble

    Unless there is some reason to change to the cron directory,

    Code:
    /usr/local/bin/php  -q  /home/kbjr/cron/cleanPackages.php
    should run the code.

    Code:
    3	0	*	*	*
    will make it run at 12:03 AM every day.

  3. #3
    kbjradmin's Avatar
    kbjradmin is offline x10 Elder kbjradmin is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Washington State, USA
    Posts
    512

    Re: Cron trouble

    ah, /usr/local/bin/php . . .
    i didn't know php was in local . . .

    i'll try that and see if it works, unfortunately i won't know until tomorrow morning :\

  4. #4
    dlukin is offline x10 Lieutenant dlukin is on a distinguished road
    Join Date
    Oct 2009
    Posts
    427

    Re: Cron trouble

    Depending on what it does, for testing only, you can try:

    Code:
    */15	*	*	*	*
    Which should run it every 15 minutes. So you will have your answer in 15 minutes.

  5. #5
    kbjradmin's Avatar
    kbjradmin is offline x10 Elder kbjradmin is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Washington State, USA
    Posts
    512

    Re: Cron trouble

    that's a good idea . . . i'll try that and reply in 15 . . .

  6. #6
    kbjradmin's Avatar
    kbjradmin is offline x10 Elder kbjradmin is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Washington State, USA
    Posts
    512

    Re: Cron trouble

    nope, still not working . . .

  7. #7
    misson is offline Community Advocate misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,391

    Re: Cron trouble

    The problem might lie with the script rather than the cron job. Does cleanPackages.php run from the browser (once you make it browser accessible)? What's the output? Any error messages?
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  8. #8
    fortwienix is offline x10Hosting Member fortwienix is an unknown quantity at this point
    Join Date
    Jan 2010
    Posts
    9

    Re: Cron trouble

    Each script that runs in a cron job must also run when you put the command directly at your console. If you don't have shell access then try to use the exec function of php.

    Try to capture all output of the script. In the exec call you would do something like:
    PHP Code:
    exec('/usr/local/bin/php your_script.php some_arg1 some_arg2 2>&1'$output$ret); 
    If I remember correctly, $output is an array. Each element is one line of the output. In $ret the exit code of the php process is stored. This should be 0 on success.

  9. #9
    Livewire's Avatar
    Livewire is offline Abuse Compliance Officer Livewire is a glorious beacon of lightLivewire is a glorious beacon of light
    Join Date
    Jul 2005
    Location
    Behind a keyboard.
    Posts
    8,925

    Re: Cron trouble

    Quote Originally Posted by fortwienix View Post
    Each script that runs in a cron job must also run when you put the command directly at your console. If you don't have shell access then try to use the exec function of php.

    Try to capture all output of the script. In the exec call you would do something like:
    PHP Code:
    exec('/usr/local/bin/php your_script.php some_arg1 some_arg2 2>&1'$output$ret); 
    If I remember correctly, $output is an array. Each element is one line of the output. In $ret the exit code of the php process is stored. This should be 0 on success.
    Exec is a disabled function on x10hosting.


    TOS breakers will be suspended regardless of race, creed, national origin, hair color, or favorite food. Thanks for your understanding!

+ Reply to Thread

Similar Threads

  1. Replies: 6
    Last Post: 11-14-2009, 07:38 PM
  2. JRE trouble
    By ichwar in forum Computers & Technology
    Replies: 3
    Last Post: 07-23-2009, 11:08 PM
  3. Can a cron job kick off another cron job?
    By dmoneyman in forum Programming Help
    Replies: 8
    Last Post: 04-03-2009, 09:04 PM
  4. having trouble getting php script to work with cron
    By mikehunt22 in forum Free Hosting
    Replies: 1
    Last Post: 11-02-2008, 10:43 AM
  5. [cron problem]php-cron command not found
    By N4rk0 in forum Free Hosting
    Replies: 1
    Last Post: 01-31-2008, 12:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers