writing condition using date stamp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting writing condition using date stamp
# 1  
Old 09-08-2010
writing condition using date stamp

Hi all,

I am writing a script which i am executing using nohup command.

Code:
while ( true )
  do
    RequiredTime=06:00:00
    SysTime=`echo $(date) | awk '{print $4}'`
    if [[ $RequiredTime == $SysTime ]]; then
    body of script 
    fi 
done

this is executing 3 times at 6am. i want it execute the body of script only once can anyone help please

thanks,
Firestar

---------- Post updated at 04:16 PM ---------- Previous update was at 03:49 PM ----------

I dont under what code tags means....

i forgot to mention that i am running this code in bash
#!/bin/bash

---------- Post updated at 04:17 PM ---------- Previous update was at 04:16 PM ----------

I dont under what code tags means....

i forgot to mention that i am running this code in bash
#!/bin/bash

Last edited by Scott; 09-08-2010 at 06:02 PM.. Reason: Code tags, PLEASE!
# 2  
Old 09-08-2010
# 3  
Old 09-08-2010
Is this gud

PHP Code:

#!/bin/bash

while ( true )
  do
    
RequiredTime=06:00:00
    SysTime
=`echo $(date) | awk '{print $4}'`
    if [[ 
$RequiredTime == $SysTime ]]; then
    body of script 
    fi 
done 
This User Gave Thanks to firestar For This Post:
# 4  
Old 09-08-2010
Code:
#!/bin/bash
while ( true )
  do
    RequiredTime=06:00:00
    SysTime=`echo $(date) | awk '{print $4}'`
    if [[ $RequiredTime == $SysTime ]]; then
    body of script 
    sleep 1
    fi
done

I prefer start script from cron.
This User Gave Thanks to john1212 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Files with date and time stamp

Hi Folks, Need a clarification on files with date and time stamp. Here is my requirement. There is a file created everyday with the following format "file.txt.YYYYMMDDHHMMSS". Now i need to check for this file and if it is available then i need to do some task to the file. I tried... (6 Replies)
Discussion started by: jayadanabalan
6 Replies

2. Shell Programming and Scripting

If(Condition) Rename a file with (Date+Time) Stamp

Hi! Please see our current script: #!/usr/bin/ksh if (egrep "This string is found in the log" /a01/bpm.log) then mailx -s "Error from log" me@email.com, him@email.com </a01/bpm.log fi To the above existing script, we need to add the following change: 1) After finding the string,... (7 Replies)
Discussion started by: atechcorp
7 Replies

3. UNIX for Advanced & Expert Users

complicated date stamp pattern

Hi, I have a log file which contains lines like below: 2010-07-19 07:13:19,021 ERROR system ...(text) 2010-07-19 07:22:03,427 ERROR system ...(text) class com... (text) 2010-07-19 07:23:19,026 ERROR system ...(text) class com... (text) each line is a separate line... I am given the a... (11 Replies)
Discussion started by: a27wang
11 Replies

4. UNIX for Advanced & Expert Users

rsync - date/time stamp

Hi, We are using RSYNC for syncing remote directories and working great. Our requirement is to have the destination files with date/time stamp of when they're copied on to the destination server, NOT the date/time stamps of source files/directories. As RSYNC, by default, preserving the same... (4 Replies)
Discussion started by: prvnrk
4 Replies

5. UNIX for Dummies Questions & Answers

How to Zip the files from date Stamp to end date Stamp

Hi, I need to zip the list of files using from date Stamp to end date Stamp, How can I filter and make FromDate_EndDate.gzip? any idea? (1 Reply)
Discussion started by: redlotus72
1 Replies

6. UNIX for Dummies Questions & Answers

Date/Time Stamp

Hi All, Wondering if there is have a date added at the end of a test string. I have a hypothetical text file day one: John Paul George When the file day one is output, I'd like it to read something like this: John 101406 Paul 101406 George 101406 Day two, when the same text file... (0 Replies)
Discussion started by: JimmyFlip
0 Replies

7. Shell Programming and Scripting

Date Stamp on new file

Dear Gurus, I'm trying to move a number of files from one directory to another directory with a new date stamp. This is my script: #! /bin/csh Today_Date=`date +%Y%M%D` mv /usr/TRS/data/TS* /usr/TRS/backup/TS*.${Today_Date} when i run the script i'm getting the following errors: mv:... (14 Replies)
Discussion started by: lweegp
14 Replies

8. Shell Programming and Scripting

Date Stamp -1

I need to move files after midnight but attach the previous date to it. Moving files before midnight no proproblem but how can I move files which are created on the 22nd for example but add a date stamp of previous day? Date ='date +"Y%m%d"' gets today's date but how can I get yesterday's... (3 Replies)
Discussion started by: candle_66
3 Replies

9. Shell Programming and Scripting

Insert Time and Date Stamp

I have a directory with following files in it ABC.000.DAT ABC.001.DAT ABC.002.DAT ABC.003.DAT I want to insert time and date stamp in file names like ABC.000.YYYYMMDDHHMM.DAT I able to insert the time and date stamp at the end of filename Kindly help (1 Reply)
Discussion started by: aajmani
1 Replies

10. Shell Programming and Scripting

Date Time Stamp

I'm trying to write a script that checks the DTS of a file the compares it to the current time. If greater that 60 mins has gone by and the file has not been written to alert. So far I have the time pulled from the file but I dont know how to compare the times against a 60 min difference. ... (2 Replies)
Discussion started by: jarich
2 Replies
Login or Register to Ask a Question