How to check day name is it saturday in bash shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check day name is it saturday in bash shell script?
# 1  
Old 03-31-2018
How to check day name is it saturday in bash shell script?

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.
# 2  
Old 03-31-2018
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.

Last edited by Scrutinizer; 03-31-2018 at 10:33 AM..
# 3  
Old 03-31-2018
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...
# 4  
Old 03-31-2018
Need to add vaidation if day of week is 6 which is saturday

I have the following with in my existing bash shell file.

Code:
#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.

Last edited by cplusplus1; 03-31-2018 at 05:46 PM..
# 5  
Old 04-01-2018
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
Code:
if [ $(date +%w) = 6 ]; then

If this is not sufficiently helpful info, carefully rephrase your request.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash shell script to check if script itself is running

hi guys we've had nagios spewing false alarm (for the umpteenth time) and finally the customer had enough so they're starting to question nagios. we had the check interval increased from 5 minutes to 2 minutes, but that's just temporary solution. I'm thinking of implementing a script on the... (8 Replies)
Discussion started by: hedkandi
8 Replies

2. Shell Programming and Scripting

Writing a script to run weekly/monthly - check for weekday or day-of-the-month

Hi all, I currently have a UNIX file maintenance script that runs daily as a cron job. Now I want to change the script and create functions/sub inside it that runs on a weekly or monthly basis. To run all the scripts' daily maintenance, I want to schedule it in cron as simply maint.sh... (1 Reply)
Discussion started by: newbie_01
1 Replies

3. Homework & Coursework Questions

Bash shell - Check if value is valid directory.

1. The problem statement, all variables and given/known data: The script usage will be as follows: library.third source_directory - Your script will display an appropriate error message and exit with status 3 if no parameters are given - Your script will display an appropriate error... (2 Replies)
Discussion started by: netmaster
2 Replies

4. Shell Programming and Scripting

Script to check if last modified day is previous day

Hi, I would like to write a script that checks if a file ('counter') was modified the previous day, if so erase its contents and write 00000000 into it. For e.g. if the file 'counter' was last modified at 11.30pm on 24th May and the script runs at 12.15am of 25th May, it should erase it's... (1 Reply)
Discussion started by: hegdepras
1 Replies

5. Shell Programming and Scripting

Script to check for the newest file mutiple times a day and SCP it to another server.

Hi, I need a sample of a script that will check a specific directory multiple times throughout the day, and scp the newest file to another server. Example: current file is misc_file.txt_02272011 (the last part is the date), once that has been secure copied, another one may come in later the... (1 Reply)
Discussion started by: richasmi
1 Replies

6. Shell Programming and Scripting

Find out the day in Bash Shell script

Hello All, I need a bash shell script to find out a day from the date.For example we give the date(20100227/YYYYMMDD) then we get the day 'Saturday'. Thanks in advance, Satheesh (5 Replies)
Discussion started by: satheesh4093
5 Replies

7. Shell Programming and Scripting

Bash-Shell: If-Clause to check if file is empty

Hello, I want to checkl whether my file has text in it or not. if ; then ... if ; then ... But none of these work Can someone help me? ---------- Post updated at 09:00 AM ---------- Previous update was at 08:55 AM ---------- The code-tags caused an displayerror,... (5 Replies)
Discussion started by: ABE2202
5 Replies

8. Solaris

How to check for Saturday or Sunday

Hi , I have a date parameter passed in YYYYMMDD format , how can I check whether it is Sat or Sun on Solaris box , as we can do the same easily on linux box by using date -d YYYYMMDD '+a' . Any pointres will be really helpful . (5 Replies)
Discussion started by: harpreetanand
5 Replies

9. Shell Programming and Scripting

Check if a day eg: saturday is the Last saturday of the month!

Hi, I need to develop a script to check for the day. If the day is a Saturday then the script should check if the Saturday is the last Saturday of the month so that certain set of instruction can be executed is it is the last Saturday. I do not want to use the crontab as this needs to be part... (9 Replies)
Discussion started by: jobbyjoseph
9 Replies

10. Shell Programming and Scripting

Write a shell script to find whether the first day of the month is a working day

Hi , I am relatively new to unix... Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell.. This is very urgent. Thanks for ur help... (7 Replies)
Discussion started by: phani
7 Replies
Login or Register to Ask a Question