im working with sun Solaris 10
which legacy system, I have made a script that handles specific producer and it consists of bash/perl/posix/sqlplus/awk
around 1k lines and it works fine in standalone mode it would work as expected, but there was an issue where the script does not work in crontab I have followed a lot of suggestion through StackOverflow/stackunixexchange like:
- start with shebang
#!/bin/bash
- script with full permission 777
- right crontab time syntax
- service restarted
- loaded all environment variables in the top of the shell
- set bash at the beginning of the script in crontab bash
my issue only on that script and the rest of scripts works fine maybe because the script has to be in bash and crontab runs by default with sh or crontab load minimal environment variable
finally, I have solved the issue by inserting the needed shell into another shell and run it through the new shell by setting the new shell in crontab, after this step I can see the crontab worked fine and it can run the script but the issue the script does not do the expected job, it skips bash statements
like if statements
and other jobs like sqlplus
producers /Perl statements
can you please tell how can solve this issue, this problem happened only when scheduling the script into crontab
shell in crontab looks like :
10 10,16 * * 1,4 bash /rate/u01/WORK/MP/ERROR/USAGE_REJECTIONS/HolderUsageShell.sh
the script starts as below :
#!/bin/bash
#environment shell contains all environment variables, I have tried to run it with/without and I got the same thing
/rate/environment.sh >/dev/null
cd /rate/path/
CurrentHour=$(date +%I)
DAY_In_Word=$(date +%A)
if [[ "$DAY_In_Word" == "Monday" || "$DAY_In_Word" == "Thursday" ]] && [[ "$CurrentHour" == "10" ]]; then
.
.
.