I need some help... i mean can someone give some idea on how to implement what i want to do...
I have script called Mail.ksh which calls another script called read.ksh. read.ksh appends data to time.out file...This Mail.ksh runs everyday say 9:00AM on cron... We have like 50 Jobs on cron and read.ksh collects data form these 50 jobs and appends the data to time.out
time.out file looks like this
The mail.ksh calculates the current mantaince date using the below code
Usually the date will be previous daye ie if mail.ksh script is running at 9:00AM on 2009 01 27 then current mantaince date will be 2009 01 26
This is what the above code do.. The Mail.ksh takes the current maint date and pass it to read.ksh when will go a folder where the data of the files generated on current maint date are stored and collect the required data form them and appends the collected data to time.out
Now i want to change this... When ever mail.ksh runs it not only do the process for current maint date but also go back two dats and gets data...
like if its running on 27 then its also runs for data 26 and 25
get the data and place the data in the time.out such a way that it removes previous data and addes this data in the respective dates...
I want it to run 2 days back and remove data in time.out to respective date and place what so ever new data...
Try to separate functionality (goals) from mechanism (steps to implement). Similarly, separate the function of performing maintenance from the step of finding the date. Pass the date into the function, and if you want to use another date, just call the function (or script) again with the different date.
Now, the code above is very complicated for doing what the date command already does. And out of curiosity, who needs Julian days? Okay, so you need them. Use the date command like this:
No need for all that other stuff.
mail.ksh is going to be kept in cron so i cant give the data from out side... i want something like a for loop...
where in code i will give some x=3 so the loop starts two days back calculates date from taking out 2 days form Julian date and calls read.ksh with 2 days back date ....and when it get back it should reamove 1 from x ie x =2 and calculate date and calls read.ksh and then x=1... i want it like this...
is this possible... if so please help me in putting it right order
Last edited by bhagya2340; 01-28-2009 at 01:18 PM..
Thanks... but organally it was written by someone... i bacially not a unix person... if i change in one ksh they will ask me to change on 65 more khs... i dont want to... let it be as it is till it does the work...
I want to know about the for loop i wrote before... please let me know will it work... if i write it like that.... say me any correction i need in the loop
Thanks... but organally it was written by someone... i bacially not a unix person... if i change in one ksh they will ask me to change on 65 more khs... i dont want to... let it be as it is till it does the work...
If you change 65 files to include one file, then future changes will require only one file to change. Also, 65 files, assuming each takes a minute to change, will be an hour of your time. How long will you waste on doing it the hard way??
Quote:
I want to know about the for loop i wrote before... please let me know will it work... if i write it like that.... say me any correction i need in the loop
I m working on shell scripting and I m stuck where in my .txt file there is column as expiry date and I need to compare that date with system date and need to remove all the rows where expiry date is less than system date and create a new .txt with update. (1 Reply)
Can someone help me with the code wherein there is a file f1.txt with different column and 34 column have expiry date and I need to get that and compare with system date and if expiry date is <system date remove those rows and other rows should be moved to new file f2.txt .
I don't want to delete... (2 Replies)
i try to set linux date & time in specific format but it keep giving me error
Example :
date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
or
date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
keep giving me this error :
date: invalid date ‘19-01-2017 00:05:01'
Please use CODE tags... (7 Replies)
I have file listed like below
-rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz
-rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz
-rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz
-rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz
-rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz
I... (5 Replies)
Dear all,
I have 2 questions.
I have a file with many rows which has date of the format YYYYMMDD.
1. I need to change the date to that weeks friday date(Ex: 20120716(monday) to 20120720). Satuday/Sunday has to be changed to next week friday date too.
2. After converting the date to... (10 Replies)
Hi,
In a field, I should receive the date with time stamp in a particular field. But sometimes the vendor sends just the date or the timestamp or correctl the date×tamp. I have to figure out the the data is a date or time stamp or date×tamp.
If it is date then append "<space>00:00:00"... (1 Reply)
hi there
I have file names in different format as below
triss_20111117_fxcb.csv
triss_fxcb_20111117.csv
xpnl_hypo_reu_miplvdone_11172011.csv
xpnl_hypo_reu_miplvdone_11-17-2011.csv
xpnl_hypo_reu_miplvdone_20111117.csv
xpnl_hypo_reu_miplvdone_20111117xfb.csv... (10 Replies)
Hello gurus,
I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4:
NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Hi all,
I've used various scripts in the past to work out the date last week from the current date, however I now have a need to work out the date 1 week from a given date.
So for example, if I have a date of the 23rd July 2010, I would like a script that can work out that one week back was... (4 Replies)
Assume, I created one file three years back and I like to move the file to some other directory with the old date (Creation date)? Is it possible? Explain? (1 Reply)