The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

need cron jop php function [moved]

Discussion in 'General Discussion' started by fras, Jan 31, 2007.

  1. fras

    fras Registered

    Joined:
    Mar 28, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    hi all

    i am php programer and i am about programing informations site that need to update

    i add 30 files to cpanel cron jop by manaul

    but it not easy and take more time

    is there any additional function i use it
    in my program to add this files to cpanel cron jop automaticaly?


    and thanks to evry body
     
    #1 fras, Jan 31, 2007
    Last edited: Jan 31, 2007
  2. freedman

    freedman Well-Known Member

    Joined:
    Feb 13, 2005
    Messages:
    312
    Likes Received:
    1
    Trophy Points:
    18
    it depends which cpanel cron job you're referring to...

    if you're talking about things running as root, best is to just put a link to them in /etc/cron.daily (or hourly, monthly, etc..)

    if it's a script that runs as a user, then just install it in that users cron job the normal way.

    If it's something that you wan tto run after cpanels daily update, then make a script called /scripts/postupcp and that gets executed after the daily cpanel update.
     
  3. fras

    fras Registered

    Joined:
    Mar 28, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Hi freedman
    my dear

    i need for example to run this file http://domain.com/file.php
    as cron jop from cpanel
    so to do that i most login into cpanel
    and go to cron jop after that go to standerd
    and write the this file and made choice to run this file

    what i need do made my script do that for me automaticaly
    when i use this option to do that i gave the script site user name and site password

    i hope you got my point now
     
  4. freedman

    freedman Well-Known Member

    Joined:
    Feb 13, 2005
    Messages:
    312
    Likes Received:
    1
    Trophy Points:
    18
    search the forums for 'remote scripting' or something like that.. there have been MANY posts about how to control cpanel from scripts, which it seems is what you want to do.

    you want to effectively program or macro functions you manually do in WHM, this is documented... also search for 'cpanel api' that'll get you most of what you need
     
  5. fusioncroc

    fusioncroc Well-Known Member

    Joined:
    Sep 28, 2004
    Messages:
    261
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    U.K.
    Why not edit the crontab directly? With crontab -e username
     
  6. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    Many people forget that PHP is also a shell scripting language (CLI) and
    you can often make the script directly executable (chmod 755 or 700) and
    put in a shebang (#!) to the PHP CLI interpreter.

    Code:
    #!/usr/bin/php
    <?php
       // whatever code
    ?>
    
    More information about PHP command line capabilities is at:
    http://www.php.net/manual/en/features.commandline.php

    If you are using PHP's powerful shell scripting capability then you can
    add the PHP script directly to any cronjob just by specifying the PHP
    script file name alone as the script you want to run along with
    whatever command line parameters you want to pass to it.

    In contrast ...

    For a web based PHP script that you want to run by cronjob, you will
    need to prefix the script filename in the cronjob by "php " which basically
    will run it somewhat similiar to the CLI spoken of earlier.

    (OR)

    To have a cronjob call the script directly from the web site as though
    it were being called from a web site visitor, you would need to instead
    make the script name a full web address and prefix it with "lynx "
    in the cronjob.

    As you can see, lots of ways to call PHP scripts from cronjobs. I personally
    prefer to shebang the scripts and run them as CLI shell scripts directly
    instead of calling them from the web server. This keeps things more
    internal, uses less resources, and doesn't tie up any network sockets
    otherwise routing your script through your web server.
     
Loading...

Share This Page