varunms

Active Member
Aug 29, 2010
33
0
56
INDIA
cPanel Access Level
Root Administrator
Hi

i am developing a app for my clients for cpanel.. when a user login to cpanel and click a button which is added by me.. if that button is clicked i need to add a cron in that user's cpanel for eg

my user name is strt23
and i am login in to cpanel and clicked add cron in main page after clicking i need to view the cron added in my cpanel cron tab page
 

KostonConsulting

Well-Known Member
Verifed Vendor
Jun 17, 2010
255
1
68
San Francisco, CA
cPanel Access Level
Root Administrator
In order to find the API calls for cron, you'll need to look in /usr/local/cpanel/base/frontend/x3/cron.

In that directory, we can find cron_entries.html which calls the tag to list cron tasks:

<?cptt Cron::listcron(cron/cron_entries.tmpl) omit_extra_record=true ?>

This means that an API1/API2 call is in use. Here's the call in question:

Cron Module Documentation

You can't ask for a specific cron entry so you'll have to get a list of all the cron entries and then loop through and find just the one you want and display it.
 

varunms

Active Member
Aug 29, 2010
33
0
56
INDIA
cPanel Access Level
Root Administrator
Thanks for your reply.. but i just need to add a new corn & if user changes the settings i need to update the same cron using php

In order to find the API calls for cron, you'll need to look in /usr/local/cpanel/base/frontend/x3/cron.

In that directory, we can find cron_entries.html which calls the tag to list cron tasks:

<?cptt Cron::listcron(cron/cron_entries.tmpl) omit_extra_record=true ?>

This means that an API1/API2 call is in use. Here's the call in question:

Cron Module Documentation

You can't ask for a specific cron entry so you'll have to get a list of all the cron entries and then loop through and find just the one you want and display it.
 

KostonConsulting

Well-Known Member
Verifed Vendor
Jun 17, 2010
255
1
68
San Francisco, CA
cPanel Access Level
Root Administrator
To add a cron task, use the add_line API call:

Cron Module Documentation

You can use the cPanel PHP API class:

https://github.com/CpanelInc/xmlapi-php

Here's an example of making an API2 call:

https://github.com/CpanelInc/xmlapi-php/blob/master/Examples/api2_example_withargs.php

So, in order to add the cron task, use Cron::add_line() and then use Cron::list_cron() to get all cron entries. Then loop through and find the line that was previously added and use Cron::edit_line() to edit it:

Cron Module Documentation