Find and delete files before a job is submitted to queue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find and delete files before a job is submitted to queue
# 1  
Old 05-10-2010
Question Find and delete files before a job is submitted to queue

Hello all.

I need some help modifying the following script:

Code:
#!/bin/bash
#PBS -l nodes=1:ppn=8,walltime=48:00:00,os=centos53computeA

## To submit type: qsub x.sh

# If not an interactive job (i.e. -I), then cd into the directory where
# I typed qsub.
if [ "$PBS_ENVIRONMENT" != "PBS_INTERACTIVE" ]; then
   if [ -n "$PBS_O_WORKDIR" ]; then
     cd $PBS_O_WORKDIR
   fi
fi

# the input file is typically named something like "gamesjob.inp"
# so the script will be run like "$SCINET_RUNGMS gamessjob 00 8 8"

# load the gamess module if not in .bashrc already
# actually, it MUST be in .bashrc
# module load gamess

# run the program

/scratch/mzd/rungms $NAME 00 8 8 >& $NAME.log

This script is used to submit jobs to a computer cluster to run quantum chemistry programs. I define the $NAME variable in the command line when I run the script.

The trouble is that the program I am running requires that any files with the same name as the file that is submitted must be deleted. That is, it will not overwrite any files with the same name.

That is, I need the script to check in "/scratch/mzd/gamess-scratch/" for any files with the same name as the file that I am submitting ($NAME). If it does find any files, regardless of extension, I need the script to delete them before the job is submitted to the queue. I also need it to check the directory where the input file is for any files that have the same name ($NAME) and delete them as well, also before submitting the job to the queue.

Looking forward to working with you again and thanks in advance.
# 2  
Old 05-10-2010
Code:
find /scratch/mzd/gamess-scratch -type f -name ${NAME:-safety_net}\* -exec /bin/rm {} \;

... that'll do it....
This User Gave Thanks to quirkasaurus For This Post:
# 3  
Old 05-10-2010
Thanks! That is amazing! It works perfectly.

I realize you are probably busy, but could you explain to me each of the parts of the line you sent me?

Best regards.
# 4  
Old 05-10-2010
Quote:
Originally Posted by quirkasaurus
Code:
find /scratch/mzd/gamess-scratch -type f -name ${NAME:-safety_net}\* -exec /bin/rm {} \;

... that'll do it....

find in the directory "/scratch/mzd/gamess-scratch" of -type -file with -name ${NAME:-safety_net}\* and execute delete.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find modify and delete files

hi every one. one of my friends has writen this script and send it to me. this script can find files that add-delete-modify and also send an alert by email i'm not catch all part of it. can anyone explain me how this work #!/bin/bash START="a.txt" END="b.txt" DIFF="c.txt" mv ${START}... (4 Replies)
Discussion started by: nimafire
4 Replies

2. UNIX for Dummies Questions & Answers

Script to find the files and delete them

This is a real world problem so I think you might found this interesting. We have servers which are shared by multiple team members. Each team member has its own user id and home directory. Now with time each user starts creating files which in end caused the disk to be full. Now for creating a... (5 Replies)
Discussion started by: Rohit06
5 Replies

3. UNIX for Dummies Questions & Answers

problem submitting job to queue

Hi, I am trying to submit a job to a queue on a cluster. When I run the job ( python script) from the command line it runs without putting python at the start. The script imports everything from another congifuration file (.config) but when I submit to the queue it tells me there is no module... (0 Replies)
Discussion started by: i-dont-know
0 Replies

4. UNIX for Dummies Questions & Answers

find and delete files

hi all , i want to find and interactively delete all the files having size greater than 20 bytes using "find" and other commands..... (8 Replies)
Discussion started by: sonu_pal
8 Replies

5. Shell Programming and Scripting

How to delete the submitted at command

Hi I have submitted an at command to run next week . Now i want to remove the submitted at command . I dont want the job to run . Can anyone help me , with the command to remove the submitted at command . thanks in advance ... (3 Replies)
Discussion started by: rxg
3 Replies

6. UNIX for Dummies Questions & Answers

Cron job to delete files

Hi everyone! I'm sorry, I'm a total noob but would really appreciate any advice or help. I want to create a cron job that would run every hour and would look inside a few different folders. If any new files were created within those folders within the last hour they would be destroyed, but any... (2 Replies)
Discussion started by: jessn
2 Replies

7. Shell Programming and Scripting

A Batch job to delete files from various directories

Hi, I have a shell script to find files older than 'X' days ($2) in directory path ($1) and delete them. Like this: my_file_remover.sh /usr/home/c 90 Now, I need to modify this script and add it in CRON, so that it checks other directories also. Like: my_file_remover.sh /usr/home/c... (3 Replies)
Discussion started by: guruparan18
3 Replies

8. UNIX for Dummies Questions & Answers

Crontab job queue

My cronjob triggers the script late by 6 minutes. /var/cron/log shows that it got triggered at the right time then where can I track, the late starting of the script. Is there some queue mechanism, some log? This happens sometimes, not daily. but it affects me, whenever it happens. Logging... (1 Reply)
Discussion started by: pksingh2
1 Replies

9. UNIX for Dummies Questions & Answers

FTP a print job that's still in queue?

I have an HP-UX system that has remote print queues created on it. We're having trouble with the data so I stopped the queue from sending its data to the recieving server. I typed "lpstat -o<queue> " and I see two print jobs listed c_91428.1 and c_91429.1 but when I go to the /usr/spool/<queue>... (2 Replies)
Discussion started by: HVHS_CJR
2 Replies

10. UNIX for Dummies Questions & Answers

how to kill process while keeping the submitted job running

:confused: I have a process which was schedule to run from 8am - 6pm daily. The scripts will search & run the commands that i was predefined in the database. Ususally, there were about 6-7 jobs for each submission and each job takes about 1-2 hrs and running one by one. And, I have a cron job... (3 Replies)
Discussion started by: hk_newbie
3 Replies
Login or Register to Ask a Question