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.

Possible to run auto-add cron task with WHM plugin?

Discussion in 'cPanel Developers' started by electric, Nov 9, 2009.

  1. electric

    electric Well-Known Member

    Joined:
    Nov 5, 2001
    Messages:
    697
    Likes Received:
    1
    Trophy Points:
    18
    Hello,

    I am thinking about developing a WHM plugin, but it would need to run once every day.

    Is there a way to automatically add a task to cron when "installing" a plugin?

    The problem is that the target market of this plugin is newbie resellers and server owners.. and they might not be able to figure out how to add something to cron.

    (ie: It's hard enough to explain how to "install" a WHM plugin.. and asking them to fiddle with cron is very difficult. Thus, I'd prefer if there is some way to automate this step?)

    I hope that makes sense.
     
  2. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Joined:
    Nov 5, 2008
    Messages:
    2,557
    Likes Received:
    7
    Trophy Points:
    38
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    This type of action, to add a cron job or modify a crontab, may be performed by the custom script used to install the custom plug-in. To have a cron entry run just once a day, the entry could be added as a file in the following directory:
    Code:
    /etc/cron.daily/
     
  3. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Well, as plugins have no real unified installation method at this time there isn't a way to do this. However you could always do a touch file to check if it's run for the first time or not.


    f.ex (pseudo code):

    if ( !-e /var/cpanel/$yourplugin/.notfirsttime ) {
    install cron
    do some setup stuff
    touch /var/cpanel/$yourplugin/.notfirsttime
    }
     
Loading...

Share This Page