Is it possible to make commands in crontab run with bash instead of sh? I know you can pass commands to bash with -c, but that's annoying and I never use sh anyway.
-
don't really know what you're doing (not familiar with cron) but if you are running a script then adding a shebang to it should work, not sure if I am correct.Alvin Wong– Alvin Wong2013-10-11 17:18:15 +00:00Commented Oct 11, 2013 at 17:18
Add a comment
|
1 Answer
You should be able to set the environment variable prior to the cron job running:
SHELL=/bin/bash
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
-
3is it possible to also make it read .bashrc?Fluffy– Fluffy2013-10-10 15:46:24 +00:00Commented Oct 10, 2013 at 15:46
-
5@Fluffy
.bashrcis - by definition - for interactive shells; so when started viacron,bashwill only read this file if it is an interactive shell.umläute– umläute2013-10-10 16:03:56 +00:00Commented Oct 10, 2013 at 16:03 -
31I was able to make it read bashrc by adding
BASH_ENV="/root/.bashrc". ThanksFluffy– Fluffy2013-10-10 16:12:16 +00:00Commented Oct 10, 2013 at 16:12 -
4@Fluffy you should make that an answervol7ron– vol7ron2017-04-11 21:37:27 +00:00Commented Apr 11, 2017 at 21:37
-
4Regarding
.bashrc,bash -llooks useful, blog.endpoint.com/2015/02/cron-wrapper-keep-your-cron-jobs.htmlmpapec– mpapec2017-05-04 05:15:56 +00:00Commented May 4, 2017 at 5:15