Scripting needed for newbie

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripting needed for newbie
# 1  
Old 11-06-2009
Scripting needed for newbie


I am newbie in shell scripting

I have a file name like simple.txt which comes from Mainframe systems onto windows dir every 15 minutes daily. File name is same. Every 15 minutes it updates.
I need to write shell script to check if the file arrived every 15 min or not.
If the new file has not arrived after 30 min, I need to exit and send message and also generate log file with start-time and end-time.
At the end of the day I also need to generate another log with Start time and end-time as fields.

Please help me in scripting
# 2  
Old 11-06-2009
A self sheduling script (by using at) seems me the best. I use such a procedure to get hourly satellite images from a website)
# if the file has been updated (if the datestamp is newer than the previsously saved one)
# then save it and get the datestamp
# calculate the difference between actaul time and datestamp
# if the difference is too big (i.e. > 30 minutes) exit, error, report in logfile etc.
# calculate the time of the next check (15 minutes + 1 or 2 minutes delay depending on the precison of the update time and the delay between timestamp and availability of the file) (That will synchronize the checking with the updating)
# activate the differed launching of this script
# report in logfile

The advantage of at is that if the system is down at sheduled time it will launch the script at the next startup (not possible with cron)
Do tou have other suggestions ?
I can code that in bash if needed but yo
# 3  
Old 11-06-2009
Scripting needed for newbie

Thanks For your reply

Could you please code for me since i am new to shell scripting
# 4  
Old 11-06-2009
(not possible with cron)
How about the

from crontab(5) ?
# 5  
Old 11-06-2009
Here code that doesn't use at but sleep; it doesn't need external storage of data but runs continuously.
Wat i suggest is to log evrything in the beginning by echoing the variables to the logfile, mainly the Delay to see if you have to adjust the tolerance at another value.
I let you code the different logs you want to make (i can help u) but try first the functioning of the script. You can add lines for monitoring purpose by echoing commands or start the script with the -x parameter like bash -x
File1=simple.txt    # The file to check
LogFile=simple.log # The log file
DelayMax=30 # Timeout delay
# BEGIN ##############################
while true
    StampNow=$(date +%s)/60    # stamp in minutes
    StampFile=$(date -r "$File1" +%s)/60
    let Delay=$StampNow-$StampFile
    if [ $Delay -gt $DelayMax ]
        echo "$(date) : ERROR : Timeout" >> $LogFile
        # etc.
        exit 1
    elif [ $StampFile -eq $StampOld ]
        sleep $Tolerance minutes # Retry a bit later
        let NewDelay=$StampNow-$StampFile+15+$Tolerance # To synchronize with the updating
        sleep $NewDelay minutes

nothing more before 7:00 or 8:00 GMT Smilie
frans@localhost-$ sleep 8 hours

Last edited by frans; 11-06-2009 at 08:15 PM.. Reason: it's late
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux newbie scripting help needed (timer)

Hi, Newbie to Linux needing some help with scripting, here. I've written a script that allows easily shutting down, rebooting, or exiting to terminal mode via a Dialog menu after logging out of X-server. In my .bash_profile I have startx followed by running my script,, and it... (1 Reply)
Discussion started by: Pop45398
1 Replies

2. Shell Programming and Scripting

Shell Scripting Newbie

Hi Guys, I want to create a shell script to run multiple jobs in sequence. Explaination - If I were to run each jobs individually I would have gone to folder - "abin"(where my shellscript is place) as follows cd abin abin > abc001 Now, I have list of programs which are like... (8 Replies)
Discussion started by: chaits84
8 Replies

3. Shell Programming and Scripting

Newbie help needed for comparing values

Being linux administrator my task is to keep the machines up and running .Everyday i get a report of list of machines that are up and running. it would be nice if i get list of machines that are shutdown in comparison to yesterdays report. for example.If there are 5 machines in my environment... (5 Replies)
Discussion started by: pinga123
5 Replies

4. Shell Programming and Scripting

scripting newbie... some help please?

hi all, i am just getting in to bash scripting, so don't be too harsh... i've created this little backup script, and it's just awfull... ugly, doesn't work like I want it to, the works. anyways, i was hoping some of you might help me improve it and learn a little in the process. what i... (13 Replies)
Discussion started by: jmd9qs
13 Replies

5. Shell Programming and Scripting

Hi Needed help for Unix Newbie

Hi, Can i get some help from any of you guyz on writing Unix script. my requirement is like reading a csv file, finding a specific pattern in the lines and repalce the string with new string and write it to another file. My file is file ABC123.dat Col1,Col2,Col3 102628,AB10 0,21... (2 Replies)
Discussion started by: prashant_jsw
2 Replies

6. Shell Programming and Scripting

scripting newbie needs help

I have written a script that will email a generic user when a device is "offline". I would like to enhance this by having the script lookup a contact's email and automatically add it to the MAIL_LIST. I am trying to lookup and return data based on a field common in two files File 1 ... (0 Replies)
Discussion started by: irishluck66
0 Replies

7. Shell Programming and Scripting

Scripting Newbie

Seems simple but I am having difficulty with this one: I am trying to write a single command line argument (which will be a path) - the program should print out the owner of the path. I can not get anything I write to run. Please help. (5 Replies)
Discussion started by: Kymmers7
5 Replies

8. UNIX for Dummies Questions & Answers

Shell Scripting Newbie

I'm relatively new at this scripting game, just need to learn some basic stuff for data handling. My current need is to write a script that loops through a textfile of filenames, and for each file removes the first line and re-writes that file to a new name. In fact I could do with knowing... (1 Reply)
Discussion started by: mattyjim2
1 Replies

9. HP-UX

urgent help needed on HP 9000 rp3410 server for a newbie

Hi friends i dont know whether it is the right forum to ask this or not. if its not please excuse me and please give me the link for such a forum. i am novice about HP 9000 rp3410 server and its things but i had to install and configure it. I came to know that it doesnot comes with builtin... (4 Replies)
Discussion started by: bnaravinda
4 Replies

10. UNIX Desktop Questions & Answers

Newbie help needed connecting to Internet

I have an Ultra5 with 2.56 that is connected to a network. We don't use a proxy server on the network but access the internet directly through a gateway. How do I configure the Solaris box to see the internet? Opening the internet explorer and setting HTTP; FTP etc ports to the ip of the... (3 Replies)
Discussion started by: FattyLumpkin
3 Replies
Login or Register to Ask a Question