Home Man
Today's Posts

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
# 1  
Old 06-20-2018
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!
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; 06-20-2018 at 03:53 PM.. Reason: Added CODE tags.
# 2  
Old 06-21-2018
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.

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
Script to check if files exits scriptor UNIX for Beginners Questions & Answers 7 08-19-2017 02:28 AM
Bash script for check files lfreez Shell Programming and Scripting 2 06-29-2016 09:35 AM
Shell/perl script to check for files neil.k Shell Programming and Scripting 2 06-04-2014 05:58 AM
Script to check files ownership Optimus81 Shell Programming and Scripting 12 02-08-2014 08:31 AM
How to check whether directory has files in it or not in shell script? VSom007 Shell Programming and Scripting 4 05-15-2013 01:56 PM
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
.sh script / Check for file in two directories then cat the files Loonatic Shell Programming and Scripting 2 07-27-2010 12:16 PM
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 11:34 PM.

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