Visit The New, Modern Unix Linux Community

perl script to check if empty files are created and delete them and run a shell script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl script to check if empty files are created and delete them and run a shell script
# 1  
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 script to kill and start the process in remote server?
# 2  
You don't need Perl to do that. Few simple commands will do:
find /path/to/files -type f -empy -exec rm '{}' \; -exec touch ./tmp.$$ \;; if [ -e ./tmp.$$ ]; then /path/to/restarting_script; rm ./tmp.$$; fi

Last edited by bartus11; 06-26-2010 at 01:38 PM..
# 3  
Thanks bartus11
Can you show how this can be written in script as I'm new to scripting.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #918
Difficulty: Medium
Unix time is a single signed number which increments every millisecond.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to delete empty files from specific locations

Hi, I need help in regard to developing a shell script to delete empty files from multiple specific locations. The directory paths will be stored in a text file. So the requirement is to read the text file for one specific path and then remove empty files from that particular path. Looping through... (4 Replies)
Discussion started by: Khan28
4 Replies

2. Shell Programming and Scripting

Shell script to check a file and delete old files

Hello, I needed help with a shell script where in it checks if a file exists under a directory and also checks the age of the file and delete it if it is older than 3 weeks. thanks (10 Replies)
Discussion started by: hasn318
10 Replies

3. Shell Programming and Scripting

To check whether the file is empty or not in shell script (sh)

Hi All, I need to check a file whether it exists and also whether it is empty or not. I have a code for this but it is not working as per my requirement. Can anyone pls suggest me on this. function funcFLSanityCheck { if then echo "${varFLSentFileListPath}/${varFLSentFileName}... (7 Replies)
Discussion started by: Arun1992
7 Replies

4. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies

5. Shell Programming and Scripting

Shell/perl script to check for files

Hi, I am trying to write a script for following scenario: I have a list of countries from where I receive (Indonesia, Thailand, Australia...etc) For each country, I have a list of files that they send. IND -- a,b,c TH -- p,q,r AU -- x,y,z The path for these files could... (2 Replies)
Discussion started by: neil.k
2 Replies

6. Shell Programming and Scripting

How to give full access to output files created by .sh script run via crontab?

Hi Expert, I have a .sh script in my home/new_dir/ This script creates number of output files at home/new_dir/email, home/new_dir/logs dir. I am running this script using crontab (owner root). Now this output files are getting created with rw-r----- 1 root root So if i... (2 Replies)
Discussion started by: Jeet1982
2 Replies

7. Shell Programming and Scripting

Script to delete empty files

I'm trying to write a shell script to files of zero length in a specified directory, but I keep getting errors. Would anybody be kind enough to look it over for issues? Thanks a bunch in advance. #!/bin/sh if then if then find $1 -type f -size 0 -print|xargs rm exit 0... (1 Reply)
Discussion started by: ScriptingIssues
1 Replies

8. Shell Programming and Scripting

Need to check for empty file in C shell script

I am running a C shell script. I have an output file from a previous step and I need to run "something" in the next step to check if the file is empty. If the file is empty, then the job script should finish EOJ. If the file is not empty then the job script should abend. Please help Thanks. (4 Replies)
Discussion started by: jclanc8
4 Replies

9. Shell Programming and Scripting

check in unix shell script so that no one is able to run the script manually

I want to create an automated script which is called by another maually executed script. The condition is that the no one should be able to manually execute the automated script. The automated script can be on the same machine or it can be on a remote machine. Can any one suggest a check in the... (1 Reply)
Discussion started by: adi_bang76
1 Replies

10. UNIX for Advanced & Expert Users

how to delete empty files in a shell script

I'm trying to figure out a way to delete empty files in a directory. I have a cron that runs and creates a flat file every 15 mins. However, most times at night the flat file will be empty. I'd like to run a script to delete empty files that end with *.dat Any suggestions? Rich (1 Reply)
Discussion started by: rpnuge
1 Replies

Featured Tech Videos