UNIX for Beginners Questions & Answers

If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Script to check if files are being sent

email, programming, solaris, unix & linux - unix commands

👤 Login to reply
Thread Tools Search this Thread Display Modes
Old 4 Weeks Ago
roshanbi roshanbi is offline
Registered User
Join Date: Jun 2018
Last Activity: 20 June 2018, 2:10 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Script to check if files are being sent

SunOS -s 5.10 Generic_147440-04 sun4u sparc SUNW,SPARC-Enterprise


on one system there are folders which are being created based on today's date

/data/CDR/sswitch_roa/voice/bkup/<yyyymmdd> (e.g /data/CDR/sswitch_roa/voice/bkup/20180620 – is the path for today’s files)

Files are being spooled in each of the daily folders that are created.

The script should verify for each day when files spooled in those folders are not being received for more than 1 hour - this will be done by checking the current timestamp of the files and if the timestamp of the files exceeds 1 hour, an email will be sent to the user.

Please find attached.

Can anyone please guide me with the script?

1. I should loop the directory

DATE_DIR=`date +%Y%m%d`;

cd /data/CDR/sswitch_roa/voice/bkup/$DATE_DIR



ls *.gz > /data/CDR/sswitch_roa/voice/bkup/files

for i in `cat files`


<to check i's current date and if the timestamp of the file exceeds more than 1 hour, an email will be sent to the user>
if(DATE_DIR - i's current date)>1
 then email... 





Moderator's Comments:
Script to check if files are being sent Please use CODE tags as required by forum rules!
Attached Thumbnails
Script to check if files are being sent-pastedimage_0-png   Script to check if files are being sent-pastedimage_1-png  

Last edited by RudiC; 4 Weeks Ago at 03:53 PM.. Reason: Added CODE tags.
Sponsored Links
Old 3 Weeks Ago
apmcd47 apmcd47 is offline
Registered User
Join Date: Feb 2011
Last Activity: 17 July 2018, 8:22 AM EDT
Posts: 360
Thanks: 16
Thanked 102 Times in 95 Posts
Are you checking that all the files have been sent in the last hour, or just the latest file?

Solaris is rather limited in what you can do with respect to date and file timestamps but how about something like this (untested)?

DATE_DIR=$(date +%Y%m%d)
cd /data/CDR/sswitch_roa/voice/bkup/${DATE_DIR}
typeset -Z2 hour
hour=$(( $(date +%H) - 1 ))
if [[ $hour -lt 1 ]]
then exit
touch -t $(date +"%m%d$hour%M$S") ${tmpfile}
latest_file=$(ls -t *.gz | head -1)
if /usr/xpg4/bin/test ${latest_file} -nt ${tmpfile}
# we have files newer than one hour
# nothing in the last hour
rm ${tmpfile}

This requires /bin/ksh to run the code.

I have tested some of the statements standalone on a Solaris system so I am confident you can get something to work from here.

Sponsored Links
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Bash script for check files lfreez Shell Programming and Scripting 2 06-29-2016 09:35 AM
need a shell script to extract the files from source file and check whether those files existonserve muraliinfy04 Shell Programming and Scripting 13 02-22-2012 07:14 AM
perl script to check if empty files are created and delete them and run a shell script hussa1n Shell Programming and Scripting 2 06-26-2010 09:34 PM
Need a script to copy files and check Camaro Shell Programming and Scripting 1 03-31-2010 12:19 PM
script to check files viv1 Shell Programming and Scripting 3 10-01-2008 09:17 AM

All times are GMT -4. The time now is 06:19 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password

Not a Forum Member?
Forgot Password?