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.

Default SHELL for cronjobs

Discussion in 'General Discussion' started by kazar01, Jan 6, 2014.

  1. kazar01

    kazar01 Registered

    Joined:
    Nov 2, 2013
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi everyone!

    I have a question for cPanel staff/developers: is the any way to define default shell (bash, sh, jaishell, etc.) for cPanel accounts cronjobs? I've found the following code in cPanel "Cron" module (/usr/local/cpanel/Cpanel/Cron/Edit.pm):

    Code:
    our $CRONTAB_SHELL_FILE = '/var/cpanel/crontabshell';
    Code:
    # Allow admins to specify a default SHELL setting
        if ( -e $CRONTAB_SHELL_FILE ) {
            my $cron_shell_ref = Cpanel::Config::LoadConfig::loadConfig($CRONTAB_SHELL_FILE);
            $cronshell = $cron_shell_ref->{'SHELL'};
        }

    So please advise, can I use /var/cpanel/crontabshell file to specify default shell binary for cronjobs? Or maybe there is another way to do this.

    Thanks.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    651
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Cron jobs are now run with jailshell. This is normal, and the intended behavior since cPanel 11.38. It's documented at:

    Jail System Update

    Is there a specific limitation on cron jobs that is causing issues with your scripts?

    Thank you.
     
  3. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    If the cPanel account is set to use either jailshell, or noshell, then all cron jobs for that user will run using jailshell.

    If the cPanel account is set to use any other shell (e.g. zsh, bash, etc), then it is possible to use /var/cpanel/crontabshell to set the shell for the cronjobs. To do this, using zsh as an example:

    Code:
    echo 'SHELL=/bin/zsh' > /var/cpanel/crontabshell'
    
    Keep in mind the following:

    1. The shell you specify in /var/cpanel/crontabshell must also be present in /etc/shells.
    2. The cronjob shell will only change after the crontab is modified via the cPanel UI.
     
Loading...

Share This Page