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

electric

Well-Known Member
Nov 5, 2001
780
8
318
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.
 

cPanelDon

cPanel Quality Assurance Analyst
Staff member
Nov 5, 2008
2,545
12
268
Houston, Texas, U.S.A.
cPanel Access Level
DataCenter Provider
Twitter
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?
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/
 

MattDees

Well-Known Member
Apr 29, 2005
416
1
243
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
}