The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
repeat character with printf ripat Shell Programming and Scripting 10 12-13-2007 05:52 PM
FTP repeat sending files Euler04 Shell Programming and Scripting 1 11-24-2005 10:46 AM
Repeat Commands dereckbc UNIX for Dummies Questions & Answers 6 01-04-2005 07:15 AM
any idea to repeat a action in VI myelvis UNIX for Dummies Questions & Answers 6 11-26-2003 02:21 AM
Repeat a command in a shell scotty UNIX for Dummies Questions & Answers 2 10-29-2002 10:42 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-06-2007
Registered User
 

Join Date: Sep 2007
Posts: 3
to copy and repeat

Hi All,
I have done some looking at other threads but haven't found quite what I am looking for. I am a newbie to scripting and haven't got to where I want to you but here is my basic question. I have a script to copy a file and send it to another file with a date and time stamp. What I want to do is to be able to repeat this command within the script to happen every 30 (or 45 or 60) minutes. I have looked at doing a cron job but want more maual intervention to start and stop the script. So I am looking to just have the commands in the script repeat itself after a sleep. Here is the script I have so far:

#! /bin/sh
for i in `ls sband_log_error`
do
mv $i labfiles/int/sband/$i$(date +%F-%T)
done

Thanks,
falcondown01
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-06-2007
Registered User
 

Join Date: Aug 2007
Posts: 13
use 'sleep n'
--------------------------
Usage: sleep NUMBER[SUFFIX]...
or: sleep OPTION
Pause for NUMBER seconds. SUFFIX may be `s' for seconds (the default),
`m' for minutes, `h' for hours or `d' for days. Unlike most implementations
that require NUMBER be an integer, here NUMBER may be an arbitrary floating
point number.
Reply With Quote
  #3 (permalink)  
Old 09-06-2007
Registered User
 

Join Date: Sep 2007
Posts: 3
Thanks younggun, should it be inserted at the end of the mv command?

Thanks for the info,
falcondown01
Reply With Quote
  #4 (permalink)  
Old 09-06-2007
Registered User
 

Join Date: Aug 2007
Posts: 13
whether inserted at the end of the mv command is determind by the 'sleep code' infront of the mv command or behind.
Reply With Quote
  #5 (permalink)  
Old 09-07-2007
Registered User
 

Join Date: Sep 2007
Posts: 3
Hi younggun,
Thanks for the info. I was able to finish this script today. Below is the final script and it worked for copying this file i need over and over.

#! /bin/csh
while 1
cp -p file_name /directory/to/copy/to/file_name'date '+%d%h%y_%T''
sleep 1800
end

Again Thanks for the help!
Falcondown01
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0