LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-18-2011, 06:37 PM   #1
calvinz
LQ Newbie
 
Registered: Oct 2011
Posts: 2

Rep: Reputation: Disabled
Smile Shell script to create files in terms of 2 hrs for a given time range.


Platform : AIX

hi,

as the subject says.. am trying to write a shell to create files in chunks of 2 hrs from a given time range.

detail : I have something that ran for 10hrs and if i get the data of it for the whole time it is going to be huge so i wanted to give in begin and end time so the shell can start from begin time add 2hrs to it and execute the commands further in the script and return to top add 2 more hrs for previous end time so creating 5 files for the duration of 10hrs having info of 2 hrs each.


$ abc.sh yyyymmdd-hhmi yyyymmdd-hhmi
#!/bin/ksh

BEGIN_TIME=$1
END_TIME=$2

----> Logic here to split given begin and end time in terms of 2 hrs / adding 2hrs to begin time till it reaches end time <---

commands
..
..
..

Thanks,
Calvin
 
Old 10-18-2011, 08:15 PM   #2
elucches
Member
 
Registered: Jan 2011
Posts: 91

Rep: Reputation: 8
Is the 'at' command available for AIX?
 
Old 10-18-2011, 08:17 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
The problem you've got is you can't (usually) just interrupt a prog in mid-flow. You need to be able to get the prog/process itself to only do 2hrs worth ( or a given amt of output eg break every 200MB) and then the script can re-start it, passing some kind of info as to where to continue from.

It really depends on exactly what you are doing.
Can you give more detail please?
Eg is it your src code or just a binary you can't alter? What is it doing..? You might be able to run a call to logrotate to just process the output of this prog every 2 hrs; it can handle non-log files, but it depends eg binary output is not going to work.
 
Old 10-18-2011, 09:23 PM   #4
calvinz
LQ Newbie
 
Registered: Oct 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
The problem you've got is you can't (usually) just interrupt a prog in mid-flow. You need to be able to get the prog/process itself to only do 2hrs worth ( or a given amt of output eg break every 200MB) and then the script can re-start it, passing some kind of info as to where to continue from.

It really depends on exactly what you are doing.
Can you give more detail please?
Eg is it your src code or just a binary you can't alter? What is it doing..? You might be able to run a call to logrotate to just process the output of this prog every 2 hrs; it can handle non-log files, but it depends eg binary output is not going to work.
here is more in detail..

it is with an oracle database.. a process runs for 10hrs and the details of it will be inserted into a table during the process.. this table will be huge so am trying to write a script to query the table where i can give full duration to the shell and it can be split in 5 2 hrs periods and the output created with 5 files making the output files smaller..
 
Old 10-19-2011, 01:36 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
First you say its inserting into an Oracle table (so time/size shouldn't be an issue), then you say its outputting flat files.
Which is it, or is it both?
As asked, exactly what lang are you using (eg bare SQL at cmd line, or eg Perl, or C or .... ?), have you got access to the src code or is it just a binary you can't change?
 
Old 10-20-2011, 11:17 AM   #6
elucches
Member
 
Registered: Jan 2011
Posts: 91

Rep: Reputation: 8
I apologize for insisting, but I would just use the 'at' command to run the shell script at "begin time", and inside the shell script I would time the process and the waiting hours using 'sleep' (check http://www.regatta.cs.msu.su/doc/usr...ixcmds1/at.htm for 'at' usage , and http://www.ibm.com/developerworks/li...b-terminating/ "Linux tip: Controlling the duration of scheduled jobs").
Regards,
Esteban
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to create a shell script that copies all files owned by a user BrainOfSweden Linux - Newbie 9 09-28-2011 08:22 AM
[SOLVED] Shell script to program with range of variables C.L. Programming 8 07-21-2010 10:20 AM
How can i read two files word by word at a time using any loop by shell script? vaibhavs17 Programming 16 03-19-2010 04:48 AM
Help: Create a shell script to move only files wich has stopped growing proxmity Linux - Newbie 8 07-28-2009 01:40 PM
How to create/delete temp/backup files through a shell script ? Sid2007 Programming 4 10-17-2007 02:55 PM


All times are GMT -5. The time now is 10:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration