To run the script based on dates


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To run the script based on dates
# 8  
Old 12-07-2017
Oh thats i was referring to which format the dates are being passed basically YYYY-MM-DD

Code:
sh main_script.sh 2017-12-10 12


Last edited by rbatte1; 12-07-2017 at 09:22 AM.. Reason: Added CODE & ICODE tags
# 9  
Old 12-07-2017
How about
Code:
FDT=$(date -d "$1 - 12 month" +"%Y-%m-%d")
for MP in $(seq 0 $2); do date -d "$FDT + $MP month" +"%Y-%m-%d"; done
2016-12-10
2017-01-10
2017-02-10
2017-03-10
2017-04-10
2017-05-10
2017-06-10
2017-07-10
2017-08-10
2017-09-10
2017-10-10
2017-11-10
2017-12-10

Be aware that this yields 13 iterations, for 12 months back and the current month.
# 10  
Old 12-08-2017
Thanks,

it worked for me

Last edited by rohit_shinez; 12-08-2017 at 03:18 AM.. Reason: thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Run shell script based on date file

Hi Team, I have a to run a script based on a date present in a different file which updates everyday. Kindly help with the solution. My current execution : ksh scriptname.sh 10152019. But here i want to enter this date from a file which gets updated daily. My appraoch : date file location:... (3 Replies)
Discussion started by: midhun3108
3 Replies

2. Shell Programming and Scripting

Call script parameter based on dates

Hi Guys, I am having a script which needs to be iterated based on date passed and itrate based on no of months given. #!/bin/bash var_d=$1 months=$2 sh invoke_script var_d i need to iterate the inside script something like below sh invoke_script 170101 sh invoke_script... (4 Replies)
Discussion started by: Master_Mind
4 Replies

3. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

4. Shell Programming and Scripting

Need to check links exists in the server based on that need to run the build script

Hi, I am working on a build script which will check for the links existing in the server ,then run the gen command to start the build process. Appreciate help on this. server os:sun solaris 10.Bash shell links present in the server location /spa/5.0: genver -> sa0_genver_release... (1 Reply)
Discussion started by: muraliinfy04
1 Replies

5. Shell Programming and Scripting

To run a script based on the value in text file

I have a Text file as shown below /* text file begins---------- ----------- Monthly files Loaded ------------- input_file record_count load_count reject_count ------------ ----------- ----------- ----------- 1_IN.txt 221935 221935 0 2_IN.txt 270668 270668 0 3_IN.TXT 231666 80370 151296... (7 Replies)
Discussion started by: nani1984
7 Replies

6. Shell Programming and Scripting

script to Find the files based on dates it came

I need a script to get the files for DEC the file format will be B20_abc_ancdfefg_20101209_INCR_201012100145.TXT.gz Based on the bold ones (date) i need to get the files can any one help me plzzzzzz (2 Replies)
Discussion started by: krux_rap
2 Replies

7. Shell Programming and Scripting

Shell script to find the run time based on log entries?

Shell script to find the run time based on log entries? Below is the log files content updated when the script test.sh runs. I would like to calculte the difference between first update time stamp and last update time stamp to find the run time of the script. The below log file shows the first... (1 Reply)
Discussion started by: mailtopranesh
1 Replies

8. Shell Programming and Scripting

Run a script based on the subject line of the email

Hi, I need help in running a script that would pull info from an email subject line and run a script (foo.sh). I'm pretty sure after a bit of googling that this is possible in several ways. but none was pretty clear on how to accomplish it. The part that I really need help with is getting the... (5 Replies)
Discussion started by: satekn
5 Replies

9. Shell Programming and Scripting

Need script to generate all the dates in DDMMYY format between 2 dates

Hello friends, I am looking for a script or method that can display all the dates between any 2 given dates. Input: Date 1 290109 Date 2 010209 Output: 300109 310109 Please help me. Thanks. :):confused: (2 Replies)
Discussion started by: frozensmilz
2 Replies

10. Shell Programming and Scripting

trigger a script based on the run status of another scipt

Im a newbee.. I have a script which runs few times daily. I want to write another script which should pick up the latest log generated from the last run of the first job and trigger a thrid script if the first script runs successfuly. Please help... Cheers (1 Reply)
Discussion started by: Athena
1 Replies
Login or Register to Ask a Question