cronjob bash script called within another shell script not working
I have a shell script which calls a bash script within it. when I run this shell script manually it works fine however when I schedule this thru cronjob, the bash script is not doing the intended job.
shell script is as follows:
#!/usr/bin/sh
SHDIR=/oracle/CMC/scripts/utils/SCTempConst
export ORACLE_SID ORACLE_HOME SHDIR TIMESTMP DATESTAMP
cd $SHDIR
TO=<actual email address>
BCC=<actual email address>
if [ -f /oracle/CMC/scripts/utils/SCTempConst/SCTempConst.xlsx ]
then
SUBJECT="Subject ...."
ATTCH=SCTempConst.xlsx
export TO BCC SUBJECT ATTCH SHDIR
./BNSendMail.sh
fi
the BNSendmail is as follows:
#!/bin/bash
cd ${SHDIR}
FROM="<from email id>"
boundary="ZZ_/afg6432dfgkl.94531q"
body=`cat msg.txt`
# Build headers
{
printf '%sn' "From: $FROM
To: $TO
Cc: $CC
Bcc: $BCC
Subject: $SUBJECT
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="$boundary"
--${boundary}
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
$body
"
mimetype1=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
printf '%sn' "--${boundary}
Content-Type: $mimetype1
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="${ATTCH}"
"
base64 "${SHDIR}/${ATTCH}"
echo
# print last boundary with closing --
printf '%sn' "--${boundary}--"
} | sendmail -t -oi
As I said this is working perfectly fine when execute manually.
only when I set this as a cronjob, its not emailing.
any help is appreciated.
Thanks and regards,
basu
shell-script cron
bumped to the homepage by Community♦ 2 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
|
show 6 more comments
I have a shell script which calls a bash script within it. when I run this shell script manually it works fine however when I schedule this thru cronjob, the bash script is not doing the intended job.
shell script is as follows:
#!/usr/bin/sh
SHDIR=/oracle/CMC/scripts/utils/SCTempConst
export ORACLE_SID ORACLE_HOME SHDIR TIMESTMP DATESTAMP
cd $SHDIR
TO=<actual email address>
BCC=<actual email address>
if [ -f /oracle/CMC/scripts/utils/SCTempConst/SCTempConst.xlsx ]
then
SUBJECT="Subject ...."
ATTCH=SCTempConst.xlsx
export TO BCC SUBJECT ATTCH SHDIR
./BNSendMail.sh
fi
the BNSendmail is as follows:
#!/bin/bash
cd ${SHDIR}
FROM="<from email id>"
boundary="ZZ_/afg6432dfgkl.94531q"
body=`cat msg.txt`
# Build headers
{
printf '%sn' "From: $FROM
To: $TO
Cc: $CC
Bcc: $BCC
Subject: $SUBJECT
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="$boundary"
--${boundary}
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
$body
"
mimetype1=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
printf '%sn' "--${boundary}
Content-Type: $mimetype1
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="${ATTCH}"
"
base64 "${SHDIR}/${ATTCH}"
echo
# print last boundary with closing --
printf '%sn' "--${boundary}--"
} | sendmail -t -oi
As I said this is working perfectly fine when execute manually.
only when I set this as a cronjob, its not emailing.
any help is appreciated.
Thanks and regards,
basu
shell-script cron
bumped to the homepage by Community♦ 2 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
what is you cron entry for this ? in cron you can set SHELL var to be executed within specific shell
– klerk
Feb 16 '15 at 12:59
May or may not be related:#!/usr/bin/sh
isn't likely to be a valid shebang.
– muru
Feb 16 '15 at 13:00
1
Did you try adding the full path instead of running as ./ ?
– rahul
Feb 16 '15 at 13:05
my crontab entry is as follows:
– Basu Navindgi
Feb 16 '15 at 13:05
00 05 * * * /export/home/oracle/CMC/scripts/utils/SCTempConst/SCTempConst_Mail.
– Basu Navindgi
Feb 16 '15 at 13:06
|
show 6 more comments
I have a shell script which calls a bash script within it. when I run this shell script manually it works fine however when I schedule this thru cronjob, the bash script is not doing the intended job.
shell script is as follows:
#!/usr/bin/sh
SHDIR=/oracle/CMC/scripts/utils/SCTempConst
export ORACLE_SID ORACLE_HOME SHDIR TIMESTMP DATESTAMP
cd $SHDIR
TO=<actual email address>
BCC=<actual email address>
if [ -f /oracle/CMC/scripts/utils/SCTempConst/SCTempConst.xlsx ]
then
SUBJECT="Subject ...."
ATTCH=SCTempConst.xlsx
export TO BCC SUBJECT ATTCH SHDIR
./BNSendMail.sh
fi
the BNSendmail is as follows:
#!/bin/bash
cd ${SHDIR}
FROM="<from email id>"
boundary="ZZ_/afg6432dfgkl.94531q"
body=`cat msg.txt`
# Build headers
{
printf '%sn' "From: $FROM
To: $TO
Cc: $CC
Bcc: $BCC
Subject: $SUBJECT
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="$boundary"
--${boundary}
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
$body
"
mimetype1=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
printf '%sn' "--${boundary}
Content-Type: $mimetype1
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="${ATTCH}"
"
base64 "${SHDIR}/${ATTCH}"
echo
# print last boundary with closing --
printf '%sn' "--${boundary}--"
} | sendmail -t -oi
As I said this is working perfectly fine when execute manually.
only when I set this as a cronjob, its not emailing.
any help is appreciated.
Thanks and regards,
basu
shell-script cron
I have a shell script which calls a bash script within it. when I run this shell script manually it works fine however when I schedule this thru cronjob, the bash script is not doing the intended job.
shell script is as follows:
#!/usr/bin/sh
SHDIR=/oracle/CMC/scripts/utils/SCTempConst
export ORACLE_SID ORACLE_HOME SHDIR TIMESTMP DATESTAMP
cd $SHDIR
TO=<actual email address>
BCC=<actual email address>
if [ -f /oracle/CMC/scripts/utils/SCTempConst/SCTempConst.xlsx ]
then
SUBJECT="Subject ...."
ATTCH=SCTempConst.xlsx
export TO BCC SUBJECT ATTCH SHDIR
./BNSendMail.sh
fi
the BNSendmail is as follows:
#!/bin/bash
cd ${SHDIR}
FROM="<from email id>"
boundary="ZZ_/afg6432dfgkl.94531q"
body=`cat msg.txt`
# Build headers
{
printf '%sn' "From: $FROM
To: $TO
Cc: $CC
Bcc: $BCC
Subject: $SUBJECT
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="$boundary"
--${boundary}
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
$body
"
mimetype1=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
printf '%sn' "--${boundary}
Content-Type: $mimetype1
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="${ATTCH}"
"
base64 "${SHDIR}/${ATTCH}"
echo
# print last boundary with closing --
printf '%sn' "--${boundary}--"
} | sendmail -t -oi
As I said this is working perfectly fine when execute manually.
only when I set this as a cronjob, its not emailing.
any help is appreciated.
Thanks and regards,
basu
shell-script cron
shell-script cron
edited Feb 16 '15 at 21:36
Gilles
538k12810891606
538k12810891606
asked Feb 16 '15 at 12:47
Basu NavindgiBasu Navindgi
111
111
bumped to the homepage by Community♦ 2 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 2 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
what is you cron entry for this ? in cron you can set SHELL var to be executed within specific shell
– klerk
Feb 16 '15 at 12:59
May or may not be related:#!/usr/bin/sh
isn't likely to be a valid shebang.
– muru
Feb 16 '15 at 13:00
1
Did you try adding the full path instead of running as ./ ?
– rahul
Feb 16 '15 at 13:05
my crontab entry is as follows:
– Basu Navindgi
Feb 16 '15 at 13:05
00 05 * * * /export/home/oracle/CMC/scripts/utils/SCTempConst/SCTempConst_Mail.
– Basu Navindgi
Feb 16 '15 at 13:06
|
show 6 more comments
what is you cron entry for this ? in cron you can set SHELL var to be executed within specific shell
– klerk
Feb 16 '15 at 12:59
May or may not be related:#!/usr/bin/sh
isn't likely to be a valid shebang.
– muru
Feb 16 '15 at 13:00
1
Did you try adding the full path instead of running as ./ ?
– rahul
Feb 16 '15 at 13:05
my crontab entry is as follows:
– Basu Navindgi
Feb 16 '15 at 13:05
00 05 * * * /export/home/oracle/CMC/scripts/utils/SCTempConst/SCTempConst_Mail.
– Basu Navindgi
Feb 16 '15 at 13:06
what is you cron entry for this ? in cron you can set SHELL var to be executed within specific shell
– klerk
Feb 16 '15 at 12:59
what is you cron entry for this ? in cron you can set SHELL var to be executed within specific shell
– klerk
Feb 16 '15 at 12:59
May or may not be related:
#!/usr/bin/sh
isn't likely to be a valid shebang.– muru
Feb 16 '15 at 13:00
May or may not be related:
#!/usr/bin/sh
isn't likely to be a valid shebang.– muru
Feb 16 '15 at 13:00
1
1
Did you try adding the full path instead of running as ./ ?
– rahul
Feb 16 '15 at 13:05
Did you try adding the full path instead of running as ./ ?
– rahul
Feb 16 '15 at 13:05
my crontab entry is as follows:
– Basu Navindgi
Feb 16 '15 at 13:05
my crontab entry is as follows:
– Basu Navindgi
Feb 16 '15 at 13:05
00 05 * * * /export/home/oracle/CMC/scripts/utils/SCTempConst/SCTempConst_Mail.
– Basu Navindgi
Feb 16 '15 at 13:06
00 05 * * * /export/home/oracle/CMC/scripts/utils/SCTempConst/SCTempConst_Mail.
– Basu Navindgi
Feb 16 '15 at 13:06
|
show 6 more comments
1 Answer
1
active
oldest
votes
Found the problem. it was not finding sendmail
when executed through cron
, I had to specify the full path of /usr/sbin/sendmail
and it worked!
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f185124%2fcronjob-bash-script-called-within-another-shell-script-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Found the problem. it was not finding sendmail
when executed through cron
, I had to specify the full path of /usr/sbin/sendmail
and it worked!
add a comment |
Found the problem. it was not finding sendmail
when executed through cron
, I had to specify the full path of /usr/sbin/sendmail
and it worked!
add a comment |
Found the problem. it was not finding sendmail
when executed through cron
, I had to specify the full path of /usr/sbin/sendmail
and it worked!
Found the problem. it was not finding sendmail
when executed through cron
, I had to specify the full path of /usr/sbin/sendmail
and it worked!
edited Feb 16 '15 at 14:46
HalosGhost
3,76392236
3,76392236
answered Feb 16 '15 at 14:24
Basu NavindgiBasu Navindgi
111
111
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f185124%2fcronjob-bash-script-called-within-another-shell-script-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
what is you cron entry for this ? in cron you can set SHELL var to be executed within specific shell
– klerk
Feb 16 '15 at 12:59
May or may not be related:
#!/usr/bin/sh
isn't likely to be a valid shebang.– muru
Feb 16 '15 at 13:00
1
Did you try adding the full path instead of running as ./ ?
– rahul
Feb 16 '15 at 13:05
my crontab entry is as follows:
– Basu Navindgi
Feb 16 '15 at 13:05
00 05 * * * /export/home/oracle/CMC/scripts/utils/SCTempConst/SCTempConst_Mail.
– Basu Navindgi
Feb 16 '15 at 13:06