Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    4

    Exclamation need cron jop php function [moved]

    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
    Last edited by fras; 01-31-2007 at 04:35 AM.

  2. #2
    Member
    Join Date
    Feb 2005
    Posts
    312

    Default

    Quote Originally Posted by fras View Post
    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
    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. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    4

    Default

    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. #4
    Member
    Join Date
    Feb 2005
    Posts
    312

    Default

    Quote Originally Posted by fras View Post
    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
    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. #5
    Member
    Join Date
    Sep 2004
    Location
    U.K.
    Posts
    265

    Default

    Why not edit the crontab directly? With crontab -e username

  6. #6
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Default

    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.

Similar Threads & Tags
Similar threads

  1. need cron jop php function
    By fras in forum cPanel Developers
    Replies: 4
    Last Post: 02-10-2007, 08:49 AM
  2. Problems php file - cron job [moved]
    By bogdanovici666 in forum New User Questions
    Replies: 2
    Last Post: 05-19-2006, 09:37 AM
  3. php cron job with url parameters [moved]
    By CT Internet in forum New User Questions
    Replies: 4
    Last Post: 02-26-2006, 04:21 AM
  4. php mail() function in CRON
    By netlook in forum cPanel and WHM Discussions
    Replies: 5
    Last Post: 09-27-2005, 04:15 PM
  5. CRON with PHP and database? [moved]
    By jpistone in forum Database Discussions
    Replies: 5
    Last Post: 09-04-2005, 01:00 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube