How to check the day name,is it saturday in bash shell script.
If dayname = saturday then
run the full load
else
run just the incremental loads
end if
Thank you very much for the helpful information.
How to check the day name,is it saturday in bash shell script.
If dayname = saturday then
run the full load
else
run just the incremental loads
end if
Thank you very much for the helpful information.
I would just use a scheduler to do that. For example cron
understands weekdays. The you do not need to check the date inside the script. You can have two command line options for full and incremental if you want to use the same script for both operations.
You mean "today's long dayname", as printed by locale day
? Does it have to be the long day name, or would the day-of-week number (6) do?
Read the man date
page for its options...
I have the following with in my existing bash shell file.
#here the below impala shell command only to be executed if day is saturday dayof week=6
if [$ date +%w]=6 then
impala-shell -i $HOST_NAME --ssl -q "DROP TABLE $CURR_TAB_QUAL PURGE" 2>>$LOG_FILE
fi
if [[ $? -eq 0 ]]; then
log_message "Dropped $CURR_TAB_QUAL Successfully"
else
log_message "Drop of $CURR_TAB_QUAL Failed. Continuing" #Drop failed, still ignore and continue???
fi
Thank you very much for the helpful info.
First off: post your OS and shell versions so people in here know what they are dealing with. Assuming bash
for now.
Your question is way from clear. Are you saying that your day-of-week check doesn't work and you need it controlled / corrected?
If so: your [
(synonym for the test
command / builtin) syntax is wrong, as is the "command substitution" syntax. Try
if [ $(date +%w) = 6 ]; then
If this is not sufficiently helpful info, carefully rephrase your request.