Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Predefined Cron for all new accounts?

Discussion in 'General Discussion' started by Mayc, Mar 7, 2018.

  1. Mayc

    Mayc Member

    Joined:
    Oct 11, 2017
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,961
    Likes Received:
    1,824
    Trophy Points:
    363
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Mayc

    Mayc Member

    Joined:
    Oct 11, 2017
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    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?
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,961
    Likes Received:
    1,824
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice