Predefined Cron for all new accounts?

Mayc

Member
Oct 11, 2017
11
0
1
Spain
cPanel Access Level
Root Administrator
Hello, a question I can't answer. Is there any way to predefine a Cron task that already appears by default configured in all new accounts when creating them??
thanks
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,243
463
Hello,

Yes, you can setup a custom bash script that makes use of the Cron::add_line cPanel API 2 function. Then, configure the custom bash script to automatically run during the account creation process as part of a post account creation hook. Here's some documentation to get you started:

cPanel API 2 Functions - Cron::add_line - Developer Documentation - cPanel Documentation
Tutorial - Create a Standardized Hook - Developer Documentation - cPanel Documentation
Guide to Standardized Hooks - Whostmgr Functions - Developer Documentation - cPanel Documentation

Thank you.
 

Mayc

Member
Oct 11, 2017
11
0
1
Spain
cPanel Access Level
Root Administrator
Hello,

Yes, you can setup a custom bash script that makes use of the Cron::add_line cPanel API 2 function. Then, configure the custom bash script to automatically run during the account creation process as part of a post account creation hook. Here's some documentation to get you started:

cPanel API 2 Functions - Cron::add_line - Developer Documentation - cPanel Documentation
Tutorial - Create a Standardized Hook - Developer Documentation - cPanel Documentation
Guide to Standardized Hooks - Whostmgr Functions - Developer Documentation - cPanel Documentation

Thank you.
Thanks.
I created a hook (creating accoun) that creates the cron file with the lines in /var/spool/cron. I can see the task created in the client panel, but I don't know if there's anything else behind the scenes that escapes me. Would this approach also be valid or wouldn't run?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,243
463
Hello,

Yes, manually editing the /var/spool/cron/$username file is also a valid method of setting up the cron job. Note that if you are assigning the account "No Shell" or "Jailed Shell Access", the first line in the user's cron file should match the following:

Code:
SHELL="/usr/local/cpanel/bin/jailshell"
Thank you.