Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Running cron with wrong shell

 
Highlighted
Occasional Visitor

Running cron with wrong shell

Hello,

I have cron job which runs script, the problem is that by default shell is /usr/bin/sh and not the /sbin/sh or usr/local/bin/bash . I've already tried adding different shebang and cronjob as 5, 10 * * * */usr/local/bin/bash /opt/scripts/script.sh. At the moment I cannot change /etc/passwd to use other shell for an user. Is there any other way to force run cron with other shell? 

I also receive warning: commands will be executed using /usr/bin/sh message as I edit crontab..

Script perfectly runs on all shells exepct for /usr/bin/sh which misses some of libraries, I guess.

3 REPLIES 3
Highlighted
Acclaimed Contributor

Re: Running cron with wrong shell

As long as your script has #! on first line, you don't need to mention the shell in crontab.

 

>  /usr/bin/sh which misses some of libraries,

What libraries are missing?  Do you get an error when you invoke /usr/bin/sh?

Occasional Visitor

Re: Running cron with wrong shell

I thought so too, but if I try to run script with bash, - it works like charm and it does not work while on cron job or neither with /usr/bin/sh script.sh.

#! has no effect at all.

About the libraries, I read somewhere on internet that /usr/bin/sh misses some of the libraries, not sure about that. Tomorrow I'll try to run it and check it for errors.

 

Highlighted
Acclaimed Contributor

Re: Running cron with wrong shell

> I read somewhere on internet that /usr/bin/sh misses some of the libraries,

 

Not misses but uses extra shlibs.  If they are missing, your installation is broken.