Replicating jobs, renaming outout


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replicating jobs, renaming outout
# 1  
Old 06-09-2012
Replicating jobs, renaming outout

Can anyone tell me if it's possible to write a script that will repeat the same job several times but give the output a slightly different name each time (i.e. change or add a number at the end of the output file)? Here is the script I use to run a single job:

Code:
#!/bin/bash
#PBS -N job0
#PBS -l select=1:ncpus=1:mem=15gb
#PBS -k oe
#PBS -q workq
#PBS -l walltime=72:00:00
#PBS -M user@gmail.com
#PBS -m ea

source /etc/profile.d/modules.sh
module purge
module add gcc/4.5.1

cd $PBS_O_WORKDIR

/scratch/user/program -iprogram_0.u -oprogram_0.out

I know I can write separate bash files for each job but I want to know if I can write a script that will replicate jobs AND give the output a new name, without having to specify that all in a another bash file. Thanks.

Last edited by Scrutinizer; 06-09-2012 at 09:00 AM.. Reason: code tags
# 2  
Old 06-09-2012
You have already used a variable in the statement

Code:
cd $PBS_O_WORKDIR

You can do the same with the output files name. There are some special variables which content is maintained by the system and which you could use to modify the name of your output file.

For instance, there is "$$", which is the process number of the running process (your script). For instance:

Code:
outfile="program_0.$$.out"

...

/scratch/user/program -iprogram_0.u -o$outfile

This will be unambiguous, but not very helpful if you want to sort the files by i.e. date. You can also use the output of the date command to achieve this. See man date for various formats of output, one plausible version would be:

Code:
outfile="program_0.$(date +"%Y%m%d.%H:%M:%S").out"

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Glusterfs not replicating

0 down vote favorite I have replicated glusterfs on two servers, if i create file on one server it doesnt reflect on other, if i try to heal the volume on node2 i get this error Commit failed on node2. Please check log file for details. glustershd.log E 0-test-client-3: connection to... (0 Replies)
Discussion started by: davidbob
0 Replies

2. Shell Programming and Scripting

Replicating certain lines in a textfile

I am very new to to shell scripting and facing a problem that I can't seem to solve. I want to write a bash script that edits file1.txt and saves it as file2.txt. This is what the files should look like: file1: textline1 textline2 startCopy copyThis endCopy textline3 textline4 file2: ... (6 Replies)
Discussion started by: sandy90
6 Replies

3. Shell Programming and Scripting

awk to indent file outout

i have a file that contains information such as this: hostname.sky.net === 12.39.59.35 hostname.sky.net === 12.39.59.35 hostname.sky.net === 12.39.59.35 hostname-newyork.sky.net ==== 13.45.35.24 hostname-newyork.sky.net ==== 13.45.35.24... (3 Replies)
Discussion started by: SkySmart
3 Replies

4. UNIX for Dummies Questions & Answers

Replicating content using sed

if we want to replicate the content of the file twice, then we can use sed 'p' filename In the same way, if i want to replicate the content thrice or 4 times, how we can achieve in SED? Thanks (5 Replies)
Discussion started by: pandeesh
5 Replies

5. UNIX for Dummies Questions & Answers

Replicating many rows in unix

Hi If my input is abcdefgh ijklmnop then the output should be: abcdefgh abcdefgh abcdefgh abcdefgh ijklmnop (6 Replies)
Discussion started by: pandeesh
6 Replies

6. Shell Programming and Scripting

waiting on jobs in bash, allowing limited parallel jobs at one time, and then for all to finish

Hello, I am running GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu). I have a specific question pertaining to waiting on jobs run in sub-shells, based on the max number of parallel processes I want to allow, and then wait... (1 Reply)
Discussion started by: srao
1 Replies

7. Shell Programming and Scripting

getting requestName from xml outout in log file

hi all, i was wondering if there is an easy and smart way of greping for requestname (in bold below) from xml output from application log file on a solaris 10 system. The requestName is the actual method name which gets called e.g it could be 'getAccount' or getId or getAddress etc etc ... (1 Reply)
Discussion started by: cesarNZ
1 Replies

8. Shell Programming and Scripting

creating/using libraries Perl...blank outout?

Good morning!! Im trying to create a script that should get a list of numbers from the user (using STDIN or a list of arguments), and call my library function. #!use/bin/perl require 'my-lib.pl'; @userArray = <STDIN>; while() { chomp; last if ! /\d/; push(@userArray,&_); }... (2 Replies)
Discussion started by: bigben1220
2 Replies

9. AIX

Command for replicating a directory

Morning all, Is there a command on AIX that can replicate/synchronise two directories? I'm after functionality similar to robocopy on Windows. Scenario: I have a directory of Oracle forms for my production system and one for my dev system, these directories start off identical. The forms... (1 Reply)
Discussion started by: huggie
1 Replies

10. Shell Programming and Scripting

background jobs exit status and limit the number of jobs to run

i need to execute 5 jobs at a time in background and need to get the exit status of all the jobs i wrote small script below , i'm not sure this is right way to do it.any ideas please help. $cat run_job.ksh #!/usr/bin/ksh #################################### typeset -u SCHEMA_NAME=$1 ... (1 Reply)
Discussion started by: GrepMe
1 Replies
Login or Register to Ask a Question