Script to check if files are being sent

Login or Register to Reply

Thread Tools Search this Thread
# 1  
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:
Mod Comment Please use CODE tags as required by forum rules!
Script to check if files are being sent-pastedimage_0png
Script to check if files are being sent-pastedimage_1png

Last edited by RudiC; 06-20-2018 at 03:53 PM.. Reason: Added CODE tags.
# 2  
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 or Register to Reply

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Script to check if files exits
Hi In live system core files are generating frequently. around 10 core files in 30 mins in root file system. which is eating my space very much below is core file core.56539 core.78886 core.12302 core.80554 core.20147 I am trying to write a script which should move...... UNIX for Beginners Questions & Answers
UNIX for Beginners Questions & Answers
Bash script for check files
I created this script for check whether specific files exist or not in the given location. but when I run this its always showing Failed - Flag_lms_device_info_20160628.txt do not exist Failed - Flag_lms_weekly_usage_info_20160628.txt do not exist but both files are existing. appreciate help...... Shell Programming and Scripting
Shell Programming and Scripting
need a shell script to extract the files from source file and check whether those files existonserve
Hi, I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is # echo $0 -sh My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether...... Shell Programming and Scripting
Shell Programming and Scripting
perl script to check if empty files are created and delete them and run a shell script
I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell...... Shell Programming and Scripting
Shell Programming and Scripting
script to check files
I have a set of files in a folder, I need a script which basically checks whether each file is present or not and if any one of them is missing , the script should fail (exit out) displaying the name of the file which does not exist . this is the list of files insert_dma_prspct_daily_tmp.sql...... Shell Programming and Scripting
Shell Programming and Scripting
UNIX and Linux

Unix (trademarked as the UNIX certification mark) is a very mature family of multitasking, multiuser computer operating systems that evolved from the original AT&T Unix. Unix development starting in the 1970s by legendary Bell Labs programmers Ken Thompson, Dennis Ritchie, and others. Unix was first targeted for the Bell System and AT&T licensed Unix to outside parties. In the 1970s time period, this lead to a variety of for-profit as well as not-for-profit Unix variants.
In the early days, this included the University of California, Berkeley (BSD), Microsoft (Xenix), IBM (AIX), and Sun Microsystems (Solaris). In the early 1990s, AT&T sold their Unix rights to Novell. In 1995 Novell sold their Unix business to the Santa Cruz Operation (SCO). The UNIX trademark was passed to The Open Group, a "neutral" industry consortium. The Open Group promoted the use of the UNIX trademark for certified operating systems that comply with the Single UNIX Specification (SUS). In 2014 Apple's macOS became the Unix version with the largest global install base and macOS remains the largest Unix-user base today.
Linux is a family of open source Unix-like operating systems based on the Linux kernel. The Linux kernel is an operating system kernel first released by Linus Torvalds on 17 September 1991. Linux distributions include the Linux kernel, system software and libraries. Popular free open source Linux distributions include Debian, Fedora, and Ubuntu. Commercial Linux distributions include Red Hat Enterprise Linux and SUSE Linux Enterprise Server. Linux may be freely modified and redistributed. Anyone on the planet may create a Linux distribution for any purpose.
Please enjoy and help our forum community by "showing your work" and posting your code, even when your code is not working as expected. To help others help you, please wrap your code blocks, sample input, sample output, error messages, and other data in CODE tags and wrap your short commands and short data objects in ICODE tags. We were all beginners in the beginning. If you have any questions about how to register or how to post, please contact us in Live Chat. Thank you and enjoy this "forever free" technical support community for UNIX, Linux and computer information technology in general.