kazar01

Registered
Nov 2, 2013
2
0
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.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
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.
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,607
80
458
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.