Reccursive "at" command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reccursive "at" command
# 1  
Old 09-26-2006
Java Reccursive "at" command

Hi friends Smilie ,

Daily I've monitor one datafile in certain location at any time.
For this Iam writing one script us at command, which is as follows:
Script name: monitor.sh

---------------------------------------------------------------
!#/usr/bin/ksh

DATE=`dateformat`
DATAFILE=`ls -lrt filename* | grep "$DATE" | awk '{ print $98} '

if [ -f $DATAFILE ] ; then
ls -lrt $DATAFILE > data_$DATE.rpt ## datafile details are redirecting to report file
at 0001 tomorrow < monitor.sh ##For tomorrow schedule
else
at now < monitor.sh ## repeated till datafile found
exit
fi
---------------------------------------------------------------

The problem is, it is not executing more than 2 or 3 times.

Are there any problem with the above code?
Will this overload the cpu usage?

Pls help me
Ganapati
# 2  
Old 09-27-2006
Java

any help on this will be much appreciated!
Please advise me!
# 3  
Old 09-27-2006
Please review our rules.

Quote:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.
Thanks
ZB
# 4  
Old 09-27-2006
Apologies for this,
I'll try to avoid this kind of mistakes in future.

Thanks and Regards,
Ganapati
# 5  
Old 09-27-2006
If the file is not found, the -f test will fail.
Enclose the filename between quotes.
Code:
if [ -f "$DATAFILE" ] ; then

Replace the at now mechanism with a loop an sleep commands.
Code:
!#/usr/bin/ksh

DATE=`dateformat`

while [ 1 ]    ## Infinite loop
do
   DATAFILE=`ls -lrt filename* | grep "$DATE" | awk '{ print $9} '

   if [ -n "$DATAFILE" ] ; then    ## If file found (DATAFILE not empty)
      ls -lrt $DATAFILE > data_$DATE.rpt ## datafile details are redirecting to report file
      at 0001 tomorrow < monitor.sh ##For tomorrow schedule
      break     ## leaves infinite loop
   fi
   sleep 30   ## Wait for 30 seconds before testing file
done


Last edited by aigles; 10-11-2006 at 09:18 AM.. Reason: Correction on field number inside DATAFILE assignment
# 6  
Old 09-28-2006
Error

Thanks a lot friend.

But Im running different scripts like the same using at command.
This is causing me the problem. I want to know how many different scripts I can run using different recursive 'at' command.
In this case I dont have crontab permission and also I dont want to use crontab.

pls guide me!

Many Thanks and Regards,
Ganapati
# 7  
Old 10-11-2006
Java

The following code Iam running to monitor avalability of the datafile. Because when ever this datafile arrives, immediately one sql load job will load this datafile and move to some other location. So daily it is required to capture the timings of the datafile arrive.
The following scripting will expiring after 10 or 15 minutes and not monitoring the timings of the datafile. Iam unable to find out the reason!

Could any one please help me in this regards?

#!/usr/bin/ksh

export DATE=`date '+%b %e'`
export REP_DATE=`date '+%d-%b-%Y_%HHr-%MMin'`
cd /export/home/gisscpbat/FTP/IN/


while [ 1 ] ## Infinite loop
do

DATAFILE=`ls -lrt ancr* | grep -iw "$DATE" | awk '{print $8}'`

if [ -f "$DATAFILE" ] ; then
ls -lrt ancr* | grep -iw "$DATE" > /export/home/ITC_loke1/CRED0071/report/CRED0071_$REP_DATE.rpt
at 0001 tomorrow < CRED0071.sh
break
fi
sleep 10 ## Wait for 10 seconds before testing file

done
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. UNIX for Dummies Questions & Answers

Explanation of "total" field in "ls -l" command output

When I do a listing in one particular directory (ls -al) I get: total 43456 drwxrwxrwx 2 root root 4096 drwxrwxrwx 3 root root 4096 -rwxrwxr-x 1 nobody nobody 3701594 -rwxrwxr-x 1 nobody nobody 3108510 -rwxrwxr-x 1 nobody nobody 3070580 -rwxrwxr-x 1 nobody nobody 3099733 -rwxrwxr-x 1... (1 Reply)
Discussion started by: proactiveaditya
1 Replies

6. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

9. UNIX for Dummies Questions & Answers

how to install "source" command!/ broken "login.cl"!

Hello, I am new to this forums and this is my first "asking help" message! i have 2 problems: 1- for unknown reasons the "source" command is not avalable in my system (UBUNTU). i can't either see it in my bin directory! 2- again for unknown reasons the "login.cl" file in the home... (0 Replies)
Discussion started by: astrosona
0 Replies

10. UNIX for Advanced & Expert Users

The "PS" command was displaying*terminals named as "SYSCON"

Hi, When typing the command ps -fe.the system is showing a process called SYSCON:confused:.... I am not sure what process is that.I hava a script that kills all command staring with 'sys' but i don't want to kill syscon:( since i think it is some system process:confused: .Please help me to find... (1 Reply)
Discussion started by: kiranjose85
1 Replies
Login or Register to Ask a Question