Operating System - HP-UX
1745809 Members
3857 Online
108722 Solutions
New Discussion

Running cron with wrong shell

 
ŽSA
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
Dennis Handly
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?

ŽSA
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.

 

Dennis Handly
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.