Execute a part of shell script only after particular date and time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execute a part of shell script only after particular date and time
# 1  
Old 06-16-2007
Execute a part of shell script only after particular date and time

I have created a simple shell script... say test.sh

Contents of test.sh
================

service named restart
cp /etc/imp.conf /backup/test/
#-- if date > 15 July 2007 11:23 pm , then only issue the commans below, else exit ---
cp /etc/secondimp.conf /backup/test/
rm -f /etc/secondimp.conf

##------ End of test.sh ------ ##



So .. how do I achieve this.. a cron is set to run test.sh daily... but I want commands from line 4 to run only after 15 July 2007 11:23 pm ... if not.. the script will execute first two commands only and exit.



Please advise.
# 2  
Old 06-16-2007
Fed,
Here is one solution:
Code:
typeset -i mCurrDate
typeset -i mJulDate
mCurrDate=`date +"%Y%m%d%H%M"`  ## YYYYMMDDHHMM
mJulDate='200707152323'
if [ ${mCurrDate} -gt ${mJulDate} ]; then
  <your actions>
fi

# 3  
Old 06-16-2007
Seems to be working Smilie ... thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Extract date and time part from filename

Hi, I am facing one scenario in which I need to extract exact position of date and time from the name of the files. For example, Below is the record in which I need to extract position of YYYYMMDD,HHMISS and YYMMDD. Date and time variables can come more than once. I need to use these position... (13 Replies)
Discussion started by: Prathmesh
13 Replies

2. Shell Programming and Scripting

Date time difference in UNIX shell script

There are 2 dates, Tue Oct 1 13:40:19 2013 Sun Sept 30 10:26:23 2013 I have multiple dates like the above one. How do I calculate the date time difference and display in another column in Shell script. Please help. (3 Replies)
Discussion started by: tanmoysays
3 Replies

3. Shell Programming and Scripting

Date / Time difference in shell script

Request ID GMDCOMTM GMDRRSTIME GMDRESTIME <36812986> : : :I want to display the date -time difference in other fields. Above I have given for only 1 record. I want to calculate for all the records. (GMCOMTM - GMDRRSTM) ,(GMDRRSTM-GMDRESTM) and... (5 Replies)
Discussion started by: ghosh_tanmoy
5 Replies

4. Shell Programming and Scripting

Date / Time difference in shell script

================================================================================ Request ID GMDCOM TIME GMDRRS TIME COM-RRS ================================================================================ <36812974> Tue Oct 1 13:32:40 2013 Tue Oct 1 20:36:42 2013... (1 Reply)
Discussion started by: ghosh_tanmoy
1 Replies

5. Shell Programming and Scripting

How to do simple date (time) calculation in shell script?

Hi, I'm looking for a way to do a simple math calc during a shell script as a means of logging how long a particular task takes. For example... STARTTIME=whenever this script starts ./path/to/command.sh >>logfile.log TOTALTIME=<time at this stage of the script after above command... (7 Replies)
Discussion started by: nbsparks
7 Replies

6. Shell Programming and Scripting

How to execute a part of code at particular time

I had to execute the following code at 10:00 AM if then echo "Job done"; fi But this is not the entire piece of code, this is sub part of code which alone is to be executed at 10:00 AM, could anyone help me with this? (1 Reply)
Discussion started by: kishore kumar
1 Replies

7. Shell Programming and Scripting

Date and Time comparison using shell script

Hi, I'm having two fields in the file F1|F2 20111220|102000 F1 ->YYYYMMDD F2 ->HHMMSS Now, I need to compare this with current date & time and need to return the difference value in hours. Already, I checked with datecalc from the forum. So, need hints from Shell Gurus. Thanks (10 Replies)
Discussion started by: buzzusa
10 Replies

8. Shell Programming and Scripting

how to update date part with new increment date time

hi experts, my requirement is like this i need to develop a shell script to update date part with new incremental date time in file some 'X' which is kept at some server location incrementing every two hours.as i am new to this scripting i need support from u people,thanx in advance (1 Reply)
Discussion started by: amanmro
1 Replies

9. Shell Programming and Scripting

shell script to sort entries in a file by date and time

Hello All, Need a shell script to sort entries in a file by date and time. Below are the entries in the file, i need to sort it first by the date and then time Note :- Date is in MM/DD/YY format and date comes as the 6th & time comes on 7th coloumns respectively. 150 pbnawldb001-b... (10 Replies)
Discussion started by: ajiwww
10 Replies

10. Shell Programming and Scripting

Is it possible to get the date and time of mail which we get into our inbox using shell script?

Hello All, I need a script which extarct the date and time of the mail which is there in our inbox... I can export the mail copy into desktop making it as a textfile or something like that.. So is there anyway to get the date and time from that? (3 Replies)
Discussion started by: smarty86
3 Replies
Login or Register to Ask a Question